Skip to content

Instantly share code, notes, and snippets.

Avatar

Homam Hosseini homam

View GitHub Profile
@homam
homam / LiveScript.sublime-build
Last active Mar 31, 2019
Sublime LiveScript, Stylus, Nib Build
View LiveScript.sublime-build
{
"cmd": ["lsc", "-c", "$file"],
"selector" : "source.ls",
"path" : "/usr/local/bin"
}
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Conversion</title>
<link type="text/css" rel="stylesheet" href="radial.css" />
</head>
<body class="radial">
hello
</body>
</html>
@homam
homam / README.md
Last active Jan 3, 2016 — forked from mbostock/.block
D3 General Upadte Pattern in LiveScript
View README.md

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 / aws_ec2_cywgin.sh
Created Jan 27, 2014
SSH to AWS EC2 Ubunto from Cygwin
View aws_ec2_cywgin.sh
chmod 400 ~/.ssh/[key].pem
chgrp -R Users ~/.ssh/
ssh -i ~/.ssh/[key].pem ubuntu@[ip]
@homam
homam / AWS_S3_File_Upload.js
Created Jan 27, 2014
How to upload files to AWS S3 with NodeJS SDK
View AWS_S3_File_Upload.js
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; }
View compositions.ls
# returnA :: x -> CB x
returnA = (x) -> (callback) -> callback null, x
# bindA :: CB x -> (x -> CB y) -> CB y
bindA = (f, g) ->
(callback) ->
(err, fx) <- f!
if !!err
View Remove Duplicated Extensions.sh
for i in ./*.jpg; do mv "$i" $(echo "$i" | sed 's/\.jpg\.jpg/\.jpg/'); done
@homam
homam / find grep.sh
Created Jun 24, 2014
Find and grep to find a string in all files that match a pattern
View find grep.sh
find . -type f -name "package.json" -exec grep -l "\"express\"\\s*:\s*\".*4" {} \;
@homam
homam / child-process.ls
Last active Aug 29, 2015
Keeping child process open in node. Instead of Ctrl+c use `process.exit 0`
View child-process.ls
fs = require \fs
_ <- fs.append-file './log.txt', "Child Started #{new Date!}\n"
<- setTimeout _ , 12000
fs.append-file './log.txt', "Child Ended #{new Date!}\n\n"
@homam
homam / jqlsc.ls
Last active Aug 29, 2015
Alternative to jq CLI tool using LiveScript
View jqlsc.ls
#!/usr/local/bin/lsc -d
# example: echo "[1,2,3,4,5]" | ./jqlsc.ls "sum . map (+ 2)"
{each, obj-to-pairs} = require \prelude-ls
lsc = require \LiveScript
global <<< require \prelude-ls
trim = -> if it[*-1] == \; then it.substr 0, it.length - 1 else it
You can’t perform that action at this time.