Skip to content

Instantly share code, notes, and snippets.

View retrography's full-sized avatar

Mahmood S. Zargar retrography

  • VU Amsterdam
  • Amsterdam, Netherlands
  • X @mszargar
View GitHub Profile
@retrography
retrography / neo4R_example.R
Last active August 29, 2015 14:00 — forked from mhermans/neo4R_example.R
Fetches graph data directly from Neo4j REST API into R. Useful for R igraph users.
# Requirements
#sudo apt-get install libcurl4-gnutls-dev # for RCurl on linux
#install.packages('RCurl')
#install.packages('RJSONIO')
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
import java.util.LinkedList;
public class LevenshteinDistance {
public static final int NONE = 0;
public static final int DELETE = 1;
public static final int INSERT = 1;
public static final int REPLACE = 2;
private static int minimum(int a, int b, int c) {
@retrography
retrography / shell-sshpass-install.md
Last active November 21, 2015 21:05 — forked from arunoda/gist:7790979
Installing SSHPass

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

@retrography
retrography / 0_reuse_code.js
Created November 16, 2015 18:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@retrography
retrography / openconnect.md
Created January 14, 2016 20:35 — forked from moklett/openconnect.md
OpenConnect VPN on Mac OS X

Unfortunately, the Cisco AnyConnect client for Mac conflicts with Pow. And by "conflicts", I mean it causes a grey-screen-of-death kernel panic anytime you connect to the VPN and Pow is installed.

As an alternative, there is OpenConnect, a command-line client for Cisco's AnyConnect SSL VPN.

Here's how to get it set up on Mac OS X:

  1. OpenConnect can be installed via homebrew:

     brew update
    

brew install openconnect

import objc
import AddressBook as ab
import pprint as pp
def pythonize(objc_obj):
if isinstance(objc_obj, objc.pyobjc_unicode):
return unicode(objc_obj)
elif isinstance(objc_obj, ab.NSDate):
return objc_obj.description()
@retrography
retrography / extract.rb
Created May 15, 2016 01:52 — forked from danlucraft/extract.rb
Extract annotations from PDFs with pdf-reader gem
require 'pdf-reader'
require './markup_receiver'
doc = PDF::Reader.new(ARGV[0])
$objects = doc.objects
def is_note?(object)
object[:Type] == :Annot && [:Text, :FreeText].include?(object[:Subtype])
end
@retrography
retrography / 00-intro.md
Created June 17, 2017 18:24 — forked from mdo/00-intro.md
Instructions for how to affix an Ikea Gerton table top to the Ikea Bekant sit-stand desk frame.

Ikea Bekant standing desk with Gerton table top

@retrography
retrography / parallelRDS.R
Last active May 20, 2022 12:45 — forked from russellpierce/parallelRDS.R
Parallelize RDS compression/decompression to improve serialization performance in R
# The functions below use parallelized versions of gzip, xz, and bzip2 to
# improve compression/decompression performance of RDS serialization in R.
# Each function searches for the appropriate program (based on the required
# compression format) and if found, offloads the compression handling to the
# external program and therefore leaves R free to do the data import/export.
# The two main functions (saveRDS and readRDS) mask R's native read and write
# functions. The functions have been only tested on macOS, but they must work
# on any Linux/Unix.
#
# Requires the following packages: pxz, pbzip2, and pigz.
@retrography
retrography / bluetooth_sleep.lua
Created August 31, 2020 08:31 — forked from ysimonson/bluetooth_sleep.lua
Hammerspoon script to disable bluetooth when the computer is put to sleep. Requires `blueutil` to be installed (`brew install blueutil`).
require "string"
function checkBluetoothResult(rc, stderr, stderr)
if rc ~= 0 then
print(string.format("Unexpected result executing `blueutil`: rc=%d stderr=%s stdout=%s", rc, stderr, stdout))
end
end
function bluetooth(power)
print("Setting bluetooth to " .. power)