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
all: spi.so | |
spi.so: spi.o makefile | |
g++ -shared -o spi.so spi.o | |
cp --remove-destination spi.so /var/lib/postgresql/spi.so | |
spi.o: spi.cc makefile | |
g++ -g -O2 -Wall -std=c++11 -fpic -c -o spi.o -I/usr/include/postgresql -I/usr/include/postgresql/9.4/server spi.cc | |
clean: |
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
#![feature(mpsc_select, box_syntax)] | |
use std::io; | |
use std::process::Command; | |
use std::sync::mpsc::{channel, Receiver, Select}; | |
use std::string::FromUtf8Error; | |
use std::thread::spawn; | |
#[derive(Debug)] | |
enum PipeError { |
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 <mongo/bson/bson.h> | |
using mongo::BSONObj; using mongo::BSONObjBuilder; | |
using mongo::BSONArray; using mongo::BSONArrayBuilder; | |
using mongo::BSONElement; | |
#include <rapidjson/document.h> | |
#include <rapidjson/reader.h> | |
#include <rapidjson/writer.h> | |
#include <rapidjson/stringbuffer.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
pub fn main() { | |
let mut hot = 0u128; | |
for ix in [0, 127] {hot |= 1 << ix} | |
println! ("{:b}", hot); | |
assert! (hot & (1 << 0) != 0); | |
assert! (hot & (1 << 126) == 0); | |
assert! (hot & (1 << 127) != 0); | |
} |
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
#ifdef __CYGWIN__ // hide "__transaction_atomic" from Eclipse | |
# define STM | |
#else | |
// http://gcc.gnu.org/wiki/TransactionalMemory | |
# define STM __transaction_atomic | |
#endif | |
__thread struct event_base* EvServ::_THR_EVBASE = nullptr; | |
// evhtp threads need separate evdns to make http requests. |
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
extern crate half; // 2.3.1 | |
extern crate serde; // 1.0.164 | |
extern crate serde_json; // 1.0.99 | |
use half::f16; | |
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | |
fn f16ser<S>(fv: &f16, se: S) -> Result<S::Ok, S::Error> | |
where | |
S: Serializer, |
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
// To add this Gist to a project: | |
// | |
// npm install https://gist.github.com/25fad725870b0ada74df2bce7d115cc1.git | |
/** | |
* @param {number} level | |
*/ | |
exports.trace = function (level) { | |
const obj = {} | |
const lim = Error.stackTraceLimit |
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
# http://aaronhawley.livejournal.com/12621.html | |
(echo -en "GET / HTTP/1.1\nHost: fropl.com\n\nGET / HTTP/1.1\nHost: fropl.com\n\n"; sleep 0.1) | telnet localhost 80 | |
# Also: | |
perl -e '$| = 1; print "GET / HTTP/1.1\nHost: fropl.com\n\nGET / HTTP/1.1\nHost: fropl.com\n\n"; sleep (1)' | telnet localhost 80 | |
# Also (from https://github.com/ellzey/libevhtp/issues/86#issuecomment-19137572): | |
(echo -en "GET /1 HTTP/1.1\r\n\r\nGET /2 HTTP/1.1\r\n\r\n"; sleep 0.1) | nc localhost 8081 |
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
/__pycache__ | |
/llog |
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
use openssl::sign::Verifier; | |
use openssl::rsa::Rsa; | |
use openssl::pkey::PKey; | |
use openssl::hash::MessageDigest; | |
use serde_json::{self as json, Value as Json}; | |
pub fn firebase_id_token (headers: BTreeMap<&str, &str>, mut stream: &mut BufStream<TcpStream>) -> Result<(), String> { | |
#[derive(Deserialize, Debug)] | |
struct Post {firebase_id_token: String} |
NewerOlder