Skip to content

Instantly share code, notes, and snippets.

View scribu's full-sized avatar

Cristi Burcă scribu

View GitHub Profile
@scribu
scribu / hlc.py
Last active January 9, 2019 09:47 — forked from ntamas/hlc.py
Hierarchical link clustering algorithm of Ahn et al (see http://barabasilab.neu.edu/projects/linkcommunities/), implemented using Python and igraph for fun.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Hierarchical link clustering
============================
:Author: Tamás Nepusz
This is an implementation of the hierarchical link clustering algorithm of Ahn
et al. The results provided by this implementation match those of the original
@scribu
scribu / generate-key-mac.sh
Last active September 7, 2016 14:43 — forked from floydpink/travis-secure-key-mac.sh
Generating secure environment variables for GitHub deployment keys to be used from a Travis-CI build.
#!/usr/bin/env bash
# On OS X, use this script to generate an encrypted deployment key for Travis CI.
# Dependencies:
# gem install travis
# brew install coreutils
if [ $# -lt 1 ]; then
echo "usage: $0 <user>/<repo>"
# Install Xcode, Command Line Tools, Xquartz (on 10.8)
# In a terminal (probably best to do one thing at a time):
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54 --with-mysql
chmod -R ug+w /usr/local/Cellar/php54/5.4.7/lib/php
pear config-set php_ini /usr/local/etc/php/5.4/php.ini
<?php
/**
* Iterates over results of a query, split into many queries via LIMIT and OFFSET
*/
class QueryIterator implements Iterator {
var $limit = 500;
var $query = '';
var $global_index = 0;
@scribu
scribu / router.php
Created November 16, 2012 15:32 — forked from tamagokun/router.php
Run a Wordpress site via PHP's built-in web server
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir( $root );
$path = '/'.ltrim( parse_url( $_SERVER['REQUEST_URI'] )['path'],'/' );
if ( file_exists( $root.$path ) )
{
if ( is_dir( $root.$path ) && substr( $path,strlen( $path ) - 1, 1 ) !== '/' )
{
@scribu
scribu / .gitconfig
Created October 17, 2012 19:33 — forked from stas/.gitconfig
WordPress Git SVN config example
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
autocrlf = false
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:Courseware/buddypress-courseware.git
[branch "master"]
@scribu
scribu / gist:3906950
Created October 17, 2012 17:40 — forked from tierra/gist:3061041
Script to sync wxWidgets SVN to GitHub
#!/bin/bash
# Intial git svn clone:
# git svn clone --prefix=svn/ -A ~/.svn2git/authors -s https://svn.wxwidgets.org/svn/wx/wxWidgets wxWidgets
cd ~/svn-git-mirrors/wxWidgets;
if [ -f .sync-running-wxWidgets ]; then exit 1; fi;
touch .sync-running-wxWidgets
@scribu
scribu / latency.txt
Created May 31, 2012 09:07 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Disk seek (SSD) 100,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
@scribu
scribu / sad-php-attempt
Created February 23, 2012 22:04 — forked from anonymous/sad-php-attempt
poor attempt at php
// Find related posts
$related = p2p_type( 'brand_to_product' )->get_related( get_queried_object_id() );
// Display related posts
if ( $related->have_posts() ) :
?>
<?php while ( $related->have_posts() ) : $related->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
<?php endwhile; ?>
@scribu
scribu / generate_update.sh
Created November 20, 2011 17:06 — forked from xentek/generate_update.sh
Generate the necessary sql statements to move a WordPress site from one environment to another
#!/usr/bin/env bash
echo "@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@@ @@@ @@@@@@@@ @@@@ @@@ @@@@@@@ @@@@@@@@ @@@ @@@ "
echo "@@! !@@ @@! @@!@!@@@ @@! @@! @@! !@@ "
echo "!@! @!! !@! !@!!@!@! !@! !@! !@! @!! "
echo " !@@!@! @!!!:! @!@ !!@! @!! @!!!:! @!@@!@! "
echo " @!!! !!!!!: !@! !!! !!! !!!!!: !!@!!! "
echo " !: :!! !!: !!: !!! !!: !!: !!: :!! "
echo ":!: !:! :!: :!: !:! :!: :!: :!: !:! "