Skip to content

Instantly share code, notes, and snippets.

View j6k4m8's full-sized avatar
🧠
hi

Jordan Matelsky j6k4m8

🧠
hi
View GitHub Profile
# For general operation
sudo apt-get install build-essential git-core pkg-config automake libtool wget zlib1g-dev python-dev libbz2-dev
# For regression test suite:
sudo apt-get install libsoap-lite-perl
# Clone the source
git clone https://github.com/moses-smt/mosesdecoder.git mosesdecoder
cd mosesdecoder
#!/bin/bash
# Stolen ahem I mean borrowed from @gkiar
rawdir='HCP900/raw'
cd ${rawdir}
for i in `ls `;
do
@j6k4m8
j6k4m8 / graphml-to-json.py
Last active October 26, 2016 14:11 — forked from anderser/convert.py
Convert from NodeXL (via GraphML-format) to D3-ready json for force layout while adding modularity groups (communities) as attribute to nodes. Useful for coloring nodes via modularitygroup attribute. Requires networkx and python-louvain. First export as GraphML file from your NodeXL-sheet. Then run: >>> python convert.py -i mygraph.graphml -o ou…
#!/usr/bin/env python
import sys
import argparse
import networkx as nx
import community
from networkx.readwrite import json_graph
import json
@j6k4m8
j6k4m8 / python-color-print.md
Last active February 4, 2017 15:54
Prints in a color, or bolded, or formatted.

Pretty-print in python.

pretty_print([RED, UNDERLINE], "DANGER!")
print(
    pretty_format([YELLOW], "Careful!"),
 "Are you sure you want to do the thing?"
@j6k4m8
j6k4m8 / statestore.md
Last active February 4, 2017 15:54
Use the URL as a backend to store statefulness. Reading from the URL on a subsequent pageload will restore the state as you left it previously.

Usage

DEPRECATED: Use this instead, which is all this and more!!

Say you have a website example.com.

setState('answer', 42);
@j6k4m8
j6k4m8 / ipinfo
Last active September 21, 2017 20:40
Python: Get local, global, or router IP from the command line
#!/usr/bin/env python3
"""
Usage:
./ipinfo [router|local|global]
./ipinfo geo [ip]
For example, to get your OWN location:
./ipinfo geo $(ipinfo global)
@j6k4m8
j6k4m8 / data.Nov-2-2017.json
Last active November 3, 2017 01:46
Activity on 365papers tweets, re: media
{
"data": [{"id": "926202781534388224", "has_media": true, "favorites": 0, "retweets": 0}, {"id": "925899260981399553", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "925466309869043714", "has_media": false, "favorites": 2, "retweets": 0}, {"id": "925107363782283269", "has_media": true, "favorites": 1, "retweets": 0}, {"id": "924714332591620097", "has_media": false, "favorites": 2, "retweets": 0}, {"id": "924327510124441602", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923986889803223040", "has_media": false, "favorites": 2, "retweets": 1}, {"id": "923752187288870914", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923376386047344640", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923017521296543744", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "922573311799975936", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "922210485453426691", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "921818671022051333", "has_media
@j6k4m8
j6k4m8 / tv
Created November 5, 2017 01:25
rpi scripts
#!/usr/bin/env python
import os
import sys
import subprocess
if (sys.argv[1] == 'on'):
subprocess.check_output('/opt/vc/bin/tvservice -p', shell=True)
if len(sys.argv) > 2 and sys.argv[2] == "up":
@j6k4m8
j6k4m8 / git-nicely.md
Last active June 27, 2019 23:04
How to git nicely with others

How to Git Nicely

Pull latest master.

git checkout master
git pull origin master

Check out a new feature-branch.

@j6k4m8
j6k4m8 / vol
Created December 11, 2019 20:41
Raspberry Pi Volume Control. Use with `vol 70` for 70% volume
#!/usr/bin/env python
import subprocess
import sys
if len(sys.argv) > 1:
subprocess.check_output("amixer sset 'PCM' {}%".format(sys.argv[1]), shell=True)
else:
print(subprocess.check_output("amixer get 'PCM' | grep '%'", shell=True).split()[3].strip('[]'))