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
void example() | |
{ | |
A *a; | |
B *b; | |
a = a_new(); | |
b = b_new(a); | |
use_b(b); | |
b_delete(b); | |
a_delete(a); |
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 main | |
import ( | |
"flag" | |
"log" | |
"io" | |
"os" | |
"net/url" | |
"net/http" | |
"strings" |
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 ruby | |
require 'nokogiri' | |
ARGV.each do |file| | |
puts "Patching #{file}.." | |
f = File.open(file) | |
doc = Nokogiri::XML(f) | |
f.close | |
#doc.remove_namespaces! |
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 ruby | |
require 'pp' | |
require 'uri' | |
require 'net/http' | |
require 'octokit' | |
require 'nokogiri' | |
require 'celluloid' | |
require 'mongo' | |
require 'logger' |
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/bash | |
mkenv(){ | |
virtualenv env | |
source env/bin/activate | |
pip install Flask \ | |
Flask-WTF\ | |
Flask-SQLAlchemy\ | |
Flask-Classy\ | |
Flask-Assets\ |
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 <iostream> | |
#include <cstdint> | |
template<int i, uint64_t val, typename Function> | |
class Loop { | |
public: | |
static inline void call(Function f){ | |
f(i, val); | |
Loop<i-1, val, Function>::call(f); | |
} |
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
# save as ~/.pythonstartup.py | |
# export PYTHONSTARTUP=$HOME/.pythonstartup.py | |
# (gives you tab completion / history) | |
import readline | |
import rlcompleter | |
import atexit | |
import os | |
readline.parse_and_bind('tab: complete') |
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 sys | |
import __builtin__ | |
real_import = __builtin__.__import__ | |
def debug_import(name, locals=None, globals=None, fromlist=None, level=-1): | |
glob = globals or sys._getframe(1).f_globals | |
importer_name = glob and glob.get('__name__') or 'unknown' | |
print('{} imports {}'.format(importer_name, name)) | |
return real_import(name, locals, globals, fromlist, level) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | |
http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<artifactId>parent</artifactId> | |
<groupId>org.sonatype.mavenbook.simpleweb</groupId> | |
<version>0.8-SNAPSHOT</version> |
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> | |
#define nil NULL | |
#define ScopedFile FILE * __attribute__((cleanup(fclosep))) | |
#define ScopedMemory void * __attribute__((cleanup(freep))) | |
void fclosep(FILE **f){ | |
if (*f){ | |
fclose(*f); |