Skip to content

Instantly share code, notes, and snippets.

View elin-moco's full-sized avatar

Eddie Lin elin-moco

View GitHub Profile
@elin-moco
elin-moco / sha256-hash.py
Last active October 17, 2019 10:55
Hash URL with sha256
import hashlib
hashlib.sha256("https://www.flipkart.com/".encode("utf-8")).hexdigest()
@elin-moco
elin-moco / firefox_market_share_data.py
Created October 17, 2019 02:16
Extract Firefox Market Share Data
#!/usr/bin/env python3
"""
This script loads market data from various sources and combine them into one big file.
"""
from argparse import ArgumentParser
import os,sys
import os.path
@elin-moco
elin-moco / browser-j5-car.js
Created September 14, 2015 11:12
Browser Johnny Five RC Car Demo Code
var joystickElem = document.getElementById('joystick');
var joystick = new VirtualJoystick({
container: joystickElem,
limitStickTravel: true,
stickRadius: 60,
mouseSupport: false
});
var bsp = new BleSerialPort({address: 'd0:6a:cf:58:ee:bd'});
@elin-moco
elin-moco / test_firmata_with_blue_yeast.js
Created August 13, 2015 15:46
Testing firmata with blue yeast, run it directly with node.js
var Bluetooth = require('./lib/blue_yeast').Bluetooth;
var device = Bluetooth.connect('BleFirmata', 'd0:6a:cf:58:ee:bd');
device.on('connect', function() {
console.log('connect');
try {
this.startNotifications();
device.send(new Uint8Array([0xF0, 0x79, 0xF7]));
} catch(e) {
console.error(e);
@elin-moco
elin-moco / intcounter.js
Last active August 29, 2015 14:08
Simple Integer Counter JQuery Plugin
$.fn.countInt = function(duration, from) {
from = typeof from !== 'undefined' ? from : 0;
duration = typeof duration !== 'undefined' ? duration : 1000;
var $this = $(this);
var to = $this.text();
$this.text(from);
$this.start = function() {
var stime = new Date().getTime();
function step() {
var now = new Date().getTime();
@elin-moco
elin-moco / mq-stats.py
Created August 5, 2014 10:24
Calculate media query percentage in project
import os
import re
CSS_DIR = 'media/css/'
# CSS_PATTERN = re.compile('.+.less$')
# CSS_PATTERN = re.compile('.+.css$')
CSS_PATTERN = re.compile('.+.-all.css$')
total_files = 0
total_loc = 0
/**
* Scratch-off canvas
*
* NOTE: this code monkeypatches Function.prototype.bind() if it doesn't
* already exist.
*
* NOTE: This is demo code that has been converted to be less demo-y.
* But it is still demo-y.
*
* To make (more) correct:
@elin-moco
elin-moco / views.py
Last active December 25, 2015 22:59
Render google form in django views.py
import urllib2
from BeautifulSoup import BeautifulSoup
from django.shortcuts import render
def google_form(request, template='reg/gform.html', formkey=None):
gform = ''
if formkey:
soup = BeautifulSoup(urllib2.urlopen('https://docs.google.com/spreadsheet/viewform?formkey=%s' % formkey).read())
formResult = soup('div', {'class': 'ss-form-container'})