This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
volatile int a, b, out; | |
__attribute__((noclone,noinline)) | |
void g(void) | |
{ | |
a = -1; | |
b = 0; | |
out = a/b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Grab 'compilefunc' here: | |
# https://github.com/scottt/scottt-bin/blob/master/compilefunc | |
$ CFLAGS='-O0' compilefunc -s -l var-arg.c main | |
28 { | |
0x0000000000400823 <+0>: push %rbp | |
0x0000000000400824 <+1>: mov %rsp,%rbp | |
29 /* See 3.5.7 Variable Arugment Lists in http://www.x86-64.org/documentation/abi.pdf | |
30 * "When a function taking variable-arguments is called, %rax must be set to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
from __future__ import print_function | |
import sys | |
import collections | |
d = collections.defaultdict(int) | |
fin = sys.stdin | |
n = int(fin.readline()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <malloc.h> | |
struct Rect { | |
char a, b; | |
}; | |
typedef struct Rect Rect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
l = json.loads(open('t.json').read()) | |
l0 = [ x for x in l if u'delete' not in x ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l = [ {'created_at': None, 'foo': 'bar'}, {'delete': 1 } ] | |
[ x for x in l if 'delete' not in x ] | |
# Out: [{'created_at': None, 'foo': 'bar'}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Usage: | |
* $ git clone https://github.com/usrbinnc/netcat-cpi-kernel-module.git | |
* $ gcc array-to-ogg.c -o array-to-ogg | |
* $ ./array-to-ogg netcat-cpi-kernel-module/tracks/*data.h | |
* $ ls netcat-cpi-kernel-module/tracks/*data.ogg | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while true; do | |
time curl http://api.plate.tw/menu.php?rest_id=2 | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tw.plate; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import com.google.gson.JsonDeserializationContext; | |
import com.google.gson.JsonDeserializer; | |
import com.google.gson.JsonElement; | |
import com.google.gson.JsonParseException; | |
import java.lang.reflect.Type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SSLSocketFactory goodSslSocketFactory(Context context) { | |
KeyStore trusted = KeyStore.getInstance("BKS"); | |
InputStream in = context.getResources().openRawResource(R.raw.truststore); | |
trusted.load(in, TRUST_STORE_PASSWORD); | |
SSLContext sslContext = SSLContext.getInstance("TLS"); | |
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( | |
TrustManagerFactory.getDefaultAlgorithm()); | |
trustManagerFactory.init(trusted); | |
sslContext.init(null, trustManagerFactory.getTrustManagers(), null); | |
return sslContext.getSocketFactory(); |