Skip to content

Instantly share code, notes, and snippets.

View adambarta's full-sized avatar

Adam Barta adambarta

View GitHub Profile
@gvkhna
gvkhna / AppleMediaKeyController.h
Created August 23, 2010 20:51
Apple Media Key hotkey override
//
// AppleMediaKeyController.h
//
// Modified by Gaurav Khanna on 8/17/10.
// SOURCE: http://github.com/sweetfm/SweetFM/blob/master/Source/HMediaKeys.h
//
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction,
@zoul
zoul / OSStatus.m
Created October 19, 2010 08:21
Decode OSStatus error codes into strings.
NSString *NSStringFromOSStatus(OSStatus errCode)
{
if (errCode == noErr)
return @"noErr";
char message[5] = {0};
*(UInt32*) message = CFSwapInt32HostToBig(errCode);
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding];
}
@aemkei
aemkei / LICENSE.txt
Created October 27, 2011 17:16 — forked from 140bytes/LICENSE.txt
Lorenz Attractor - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ebidel
ebidel / handle_file_upload.php
Created April 18, 2012 03:23
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@adambarta
adambarta / mutex.c
Created July 11, 2012 15:23
Mutexes on Linux (x86_64) in userspace using futex
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sysexits.h>
#include <unistd.h>
#include <stdint.h>
#include <limits.h>
#include <asm-generic/mman.h>
@adambarta
adambarta / fan.c
Created August 7, 2012 14:49
FAN - pipe standard input to multiple command standard inputs
#include <stdio.h>
#define BUF 4096
static volatile int run = 0;
int main(char argc, char *argv[])
{
unsigned char buf[BUF];
FILE *fn[argc - 1];
@mherwig
mherwig / HttpImage
Last active December 11, 2015 09:49
HttpImage is set of tools for sending photos to devices like tablets or phone via HTTP. There is an android app for receiving and displaying photos and there is an optional shell script that is able to send photos to these android devices right after you take a photo with a camera connected to your PC or your Raspberry Pi
HttpImage Listener (Android):
You can send images via cURL to an android device running HttpImage Listener:
e.g.: curl -F imagefile@myimage.jpg http://192.168.0.2
The follwoing options are available:
nohandler=true just save image, don't display
customapp=true let's you choose the app for handling the image
e.g: curl -d nohandler=true -F imagefile@myimage.jpg http://192.168.0.2
@mrtj
mrtj / BouncyButtonViewController.h
Created February 19, 2014 10:56
iOS view controller demonstrating how to create a bouncy rubber button with the new UIView method animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: of iOS 7
#import <UIKit/UIKit.h>
@interface BouncyButtonViewController : UIViewController
@end
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@sh1n0b1
sh1n0b1 / ssltest.py
Created April 8, 2014 07:53
Python Heartbleed (CVE-2014-0160) Proof of Concept
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select