Skip to content

Instantly share code, notes, and snippets.

View nealrs's full-sized avatar
💭
code monster

Neal Shyam nealrs

💭
code monster
View GitHub Profile
@nealrs
nealrs / contractions.py
Created May 31, 2015 01:33
Expand common (and some very uncommon) english contractions
"""
this code is not mine! i shamelessly copied it from http://stackoverflow.com/questions/19790188/expanding-english-language-contractions-in-python
all credits go to alko and arturomp @ stack overflow.
basically, it's a big find/replace.
"""
import re
cList = {
"ain't": "am not",
@nealrs
nealrs / devpost-icon-black.svg
Created July 31, 2015 17:58
Devpost social icon
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nealrs
nealrs / convert.md
Created September 21, 2015 17:24
Convert XML data to JSON in Python

I recommend using the xml2json python package to convert back and forth from XML/JSON.

  1. Install it with pip: pip install xml2json

  2. Convert a file: xml2json -t xml2json -o output.json input.xml --strip_text

The output JSON won't be pretty printed (as in the attached file, but it will be valid!!)

@nealrs
nealrs / demo.html
Created September 30, 2015 20:23
Devpost Hackathon Button
<html>
<body>
<a href target="_blank" class="devpostButton" data-slug="artik" data-begin="2014-09-27 10:00 EST" data-deadline="2014-10-01 10:00 EST" data-defcss="true" >Submit your hack on Devpost</a>
<script src="devpostButton.js"></script>
</body>
</html>
@nealrs
nealrs / p0.txt
Created October 8, 2015 03:11
create animation with Rayito & ImageMagick
# (optional, default 320 240) size = size of the final image
size 1024 768
nbounces 5
# (optional, default 1) oversampling=1 no oversampling
oversampling 2
# (optional, default 60) vision = size of the visual field
vision 60
@nealrs
nealrs / index.js
Created October 23, 2015 21:17
Devpost -> image
var request = require('request');
var handlebars = require('handlebars');
var project = 'distractedness';
var url = 'http://devpost.com/software/' + project;
var api = 'https://iii3mdppm7.execute-api.us-east-1.amazonaws.com/prod/ProjectEndpoint/' + project;
var source = "<h2>{{title}}</h2><p>{{tagline}}</p><ul>{{#collaborators}}<li> <img src='{{avatar_url}}'> {{name}}</li>{{/collaborators}}</ul><ul>{{#built_with}}<li> #{{name}}</li>{{/built_with}}</ul>";
request({url: api, json: true}, function(err, res, json) {
if (err) {throw err;}
@nealrs
nealrs / zd.py
Created November 19, 2015 15:36
delete ziggeo videos
from Ziggeo import Ziggeo
ziggeo = Ziggeo("APP_TOKEN", "PRIVATE_KEY", "ENC_KEY")
print ziggeo.videos().delete("VIDEO_TOKEN")
@nealrs
nealrs / cron
Created December 12, 2015 07:46
Python script + cron job to add NextDraft articles to your Instagram list every day at 5:05pm
0 5 17 ? * MON-FRI * python ~/path/instadraft.py >> ~/path/instadraft.log
@nealrs
nealrs / responsive-screens.js
Created January 29, 2016 03:44 — forked from ryanmark/responsive-screens.js
Easy responsive screenshots with Phantom.js
/*
* Take a set of full height screenshots for a range of screensizes.
* phantomjs responsive-screens.js http://www.cnn.com/ png
*
* This will create a directory tree in your current directory which
* mirrors the URL. All files will be named with the current time.
* You can run this on a cron to build an archive of screenshots.
**/
var page = new WebPage(),
@nealrs
nealrs / gist:35554cc4bcb58df95e21
Created February 25, 2016 03:25
Google Analytics: HTML5 Video Tracking
document.addEventListener('DOMContentLoaded', init, false)
var videoId = document.getElementById('video')
//var videoTitle = videoId.getAttribute('data-description')
var videoTitle = '宝宝身边有怪物'
function init () {
videoId.addEventListener('ended', videoEnd, false)
videoId.addEventListener('timeupdate', videoTimeUpdate, false)
videoId.addEventListener('play', videoPlay, false)