Skip to content

Instantly share code, notes, and snippets.

@homam
homam / AWS_S3_File_Upload.js
Created January 27, 2014 10:08
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@homam
homam / imgur-example.html
Last active September 26, 2022 06:08
html2canvas example
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<form method="POST" enctype="multipart/form-data" action="https://www.google.com/save" id="myForm">
<input type="hidden" name="img_val" id="img_val" value="" />
</form>
<div id="more">
<h1 style='color: red'> hello </h1>
<iframe src="https://tags.mli.me/12751">
</iframe>
@homam
homam / TimerRecursion.hs
Created July 25, 2015 13:31
Timer, setInterval in Haskell
import Control.Concurrent
import Control.Exception
setInterval :: Int -> a -> (a -> IO a) -> IO ()
setInterval microsecs a action = do
mvar <- newEmptyMVar
_ <- setInterval' microsecs a mvar action
takeMVar mvar
@homam
homam / apple-script-send-imessage.sh
Last active December 23, 2020 09:51
AppleScripts for sending iMessages and Attachment
osascript send-imessage.scpt "hello" "Homam Hosseini"
osascript send-imessage-pic.scpt `realpath northamerica-neb.jpg` "Homam Hosseini"
@homam
homam / README.md
Last active December 1, 2020 22:45 — forked from mbostock/.block
D3 General Upadte Pattern in LiveScript

By adding transitions, we can more easily follow the elements as they are entered, updated and exited. Separate transitions are defined for each of the three states.

Note that no transition is applied to the merged enter + update selection; this is because it would supersede the transition already scheduled on entering and updating elements. It's possible to schedule concurrent elements by using transition.transition or by setting transition.id, but it's simpler here to only transition the x-position on update; for entering elements, the x-position is assigned statically.

Want to read more? Try these tutorials:


This fork shows how using LiveScript improves readability of D3 enter-update-exit pattern.

@homam
homam / Utils.cs
Last active August 20, 2019 16:11
My Big 2010s C# Utils
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Net.Mail;
using System.Web;
using System.Xml.Serialization;
oneToTen.reduce(function(acc, a) {
return acc + a;
}, 0)
@homam
homam / LiveScript.sublime-build
Last active March 31, 2019 13:58
Sublime LiveScript, Stylus, Nib Build
{
"cmd": ["lsc", "-c", "$file"],
"selector" : "source.ls",
"path" : "/usr/local/bin"
}
@homam
homam / .block
Created August 29, 2018 12:41 — forked from micahstubbs/.block
world map 07 Jenks natural breaks
height: 510
border: no
license CC0-1.0
WITH R AS (
SELECT (case when strpos(R.msisdn, '372') = 1 then substr(R.msisdn, 4) else R.msisdn end) as redshift_msisdn, R.msisdn as full_msisdn,
R."timestamp" as redshift_timestamp
FROM (
SELECT *
FROM dblink('redshift_server',$REDSHIFT$
SELECT u.msisdn, u.timestamp from user_sessions u
WHERE u.timestamp >= '2018-06-10Z'
AND u.offer_id = 853
AND u.country_code = 'EE'