Skip to content

Instantly share code, notes, and snippets.

@kdepp
kdepp / AudioHardware.h
Created November 19, 2019 04:48
Core Audio Header Files
/*==================================================================================================
File: CoreAudio/AudioHardware.h
Contains: API for communicating with audio hardware.
Copyright: (c) 1985-2011 by Apple, Inc., all rights reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
@parkj90
parkj90 / array.c
Last active June 9, 2019 03:13
dynamic array
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "array.h"
array_t *array_new(void) {
array_t *array = malloc(sizeof(array_t));
if (array == NULL) {
return NULL;
}
@ssudarshaniitb
ssudarshaniitb / univdb.txt
Last active June 15, 2022 17:27
University DB
-- Dataset for the University database schema from
-- Database System Concepts by Silberschatz, Korth and Sudarshan
group: UniversityDB
classroom = {
building:string, room_number:number, capacity:number
Packard, 101, 500
Painter, 514, 10
Taylor, 3128, 70
@bagder
bagder / threaded-shared-conn.c
Created December 1, 2017 10:36
multi-threaded libcurl example using a shared single connection cache
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
@tomanistor
tomanistor / problem.md
Created June 22, 2017 17:38
Sum of Digits / Digital Root

In this kata, you must create a digital root function.

A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has two digits, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers.

Here's how it works (Ruby example given):

digital_root(16)
=> 1 + 6
=&gt; 7
@JBou
JBou / SoundCloud API Endpoints.cs
Last active January 14, 2024 07:33
SoundCloud API Endpoints
//Authorization
{ ApiCommand.AuthorizationCodeFlow, new Uri("https://soundcloud.com/connect?scope=non-expiring&client_id={0}&response_type={1}&redirect_uri={2}") },
{ ApiCommand.UserAgentFlow, new Uri("https://soundcloud.com/connect?client_id={0}&response_type=token&redirect_uri={1}") },
{ ApiCommand.UserCredentialsFlow, new Uri("https://api.soundcloud.com/oauth2/token?client_id={0}&client_secret={1}&grant_type=password&username={2}&password={3}") },
{ ApiCommand.RefreshToken, new Uri("https://api.soundcloud.com/oauth2/token?client_id={0}&client_secret={1}&grant_type=refresh_token&refresh_token={2}") },
//Me
{ ApiCommand.Me, new Uri("https://api.soundcloud.com/me.json") },
{ ApiCommand.MeTracks, new Uri("https://api.soundcloud.com/me/tracks.json") },
{ ApiCommand.MeComments, new Uri("https://api.soundcloud.com/me/comments.json") },
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
@sharplet
sharplet / trap.swift
Created November 23, 2015 03:46
Simple signal handling in Swift
import Darwin
enum Signal: Int32 {
case HUP = 1
case INT = 2
case QUIT = 3
case ABRT = 6
case KILL = 9
case ALRM = 14
case TERM = 15
@thomasdarimont
thomasdarimont / hack.md
Last active October 9, 2022 06:37
This small example demonstrates how to dump the class-files of classes currently loaded in the JVM via jrunscript and internal hotspot API.

Dump loaded classes from another JVM process with Java 9

We will use jrunscript and internal hotspot API to access and export the classfile data. To do that we will use 2 jrunscript processes, a "debuggee" process and a "debugger" jrunscript process. The debugger process will attach to and inspect the debuggee process (internal) via hotspot API. For this example we use the "latest" Java 9 build b41 on OSX.

Motivation for this example was given by the fact that the latest JDK 9 release b41 doesn't ship an rt.jar anymore. The content from rt.jar was now moved to a new platform specific format with the extension .jimage in the JDK_HOME/lib/modules.

You can find more information about the new packaging in Java 9 in Mark Reinholds blogpost: http://mreinhold.org/blog/jigsaw-modular-images

@bellbind
bellbind / avcapture.m
Last active June 19, 2023 01:21
[objective-c][macosx]capturing image from webcam
// capture image from webcam(e.g. face time)
// for OSX 10.9 (use AVFoundation API instead of deprecated QTKit)
// clang -fobjc-arc -Wall -Wextra -pedantic avcapture.m
// -framework Cocoa -framework AVFoundation -framework CoreMedia
// -framework QuartzCore -o avcapture
#import <AVFoundation/AVFoundation.h>
#import <AppKit/AppKit.h>
@interface Capture : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>