Skip to content

Instantly share code, notes, and snippets.

View smoll's full-sized avatar

Shujon Mollah smoll

View GitHub Profile
@smoll
smoll / add_up_single_column_in_tsv.rb
Last active August 29, 2015 14:04
Using Ruby and smarter_csv gem to process Statement Exports (Tab-separated values file with headers)
require 'benchmark'
require 'smarter_csv'
require 'bigdecimal' # using BigDecimal instead of Float
require 'bigdecimal/util'
# modify these variables
filename = "new_statement_detail_Yorck_Eysel_10942_Q12014.txt" # put the real path to your .txt file here
rows_per_chunk = 10000 # processes this many rows in each "chunk"
name_of_column = "Label Share Net Receipts"
number_format = "EU" # set this to "EU" or "US"
@smoll
smoll / gist:292a352839a2f503f588
Created September 15, 2014 16:29
hello world form from html in a URL
# Enter this into URL:
data:text/html,<h1 id="welcome">Hello, World!</h1><form>Name: <input type="text" id="name" required><br>Notes: <input type="text" id="notes"><input type="submit" id="submit_form"></form>
# Modified:
data:text/html,<h1 id="welcome">Hello, World!</h1><form>Name: <input type="text" id="name" required><br>Notes: <input type="text" id="notes"><input type="submit" id="new_submit"></form>
@smoll
smoll / rerun.rb
Created September 29, 2014 15:19
Modify cucumber v1.3.17 rerun formatter to only rerun failed scenarios
require 'cucumber/formatter/io'
module Cucumber
module Formatter
# The formatter used for <tt>--format rerun</tt>
#
# This formatter keeps track of all failing features and print out their location.
# Example:
#
# features/foo.feature:34 features/bar.feature:11:76:81
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@smoll
smoll / unparse.rb
Last active November 5, 2015 18:39
Adapted from the unparser usage example, at https://github.com/mbj/unparser#usage
require 'parser/current'
require 'unparser'
require 'byebug'
module YourHelper
def s(type, *children)
Parser::AST::Node.new(type, children)
end
end
@smoll
smoll / gist:7f552ff0eb12a7c362f321b9f56aad65
Created June 14, 2016 13:33 — forked from bruchu/gist:8230184
change s3 content-type using aws ruby sdk
bash:
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export AWS_REGION='us-east-1'
irb or ruby script:
require 'aws-sdk'
s3 = AWS::S3.new
@smoll
smoll / USING-DIFFMERGE.md
Last active October 21, 2023 23:37
Using DiffMerge as your git mergetool (for Mac OS X / macOS)
@smoll
smoll / Auth Class
Created January 6, 2017 20:05 — forked from singledigit/Auth Class
Pattern for using Cognito User Pools as authentication against Cognito Identity
import {inject} from 'aurelia-framework';
import {Session} from './session';
@inject(Session)
export class Auth {
// App specific
userPoolId = 'us-east-1_fgCWraBkF';
appClientId = '57lq262n28o7ddt8i36jcjj7qd';
@smoll
smoll / scrapeGoogleImages.js
Created July 11, 2017 14:29 — forked from flovv/scrapeGoogleImages.js
scrapeGoogleImages_file1
var url ='https://www.google.de/search?q=Yahoo+logo&source=lnms&tbm=isch&sa=X';
var page = new WebPage()
var fs = require('fs');
var vWidth = 1080;
var vHeight = 1920;
page.viewportSize = {
width: vWidth ,
height: vHeight
@smoll
smoll / post-npm-install.js
Last active February 16, 2018 21:53
Quick 'n Dirty hack to rewrite minify.js to make join-monster play nice with React Native
const fs = require('fs')
const path = require('path')
const rewriteFile = (file, value, replacement) => {
const data = fs.readFileSync(file, 'utf-8')
const replaced = data.replace(value, replacement)
fs.writeFileSync(file, replaced, 'utf-8')
}
const rewriteMinifyJs = () => {