Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# this script will convert every file using babel
# in the lib folder which ends with es6.js
# and put it into the same folder using es5 prefix
# so lib/bla.es6.js will become lib/bla.es5.js
files=$(ls ./lib/*.es6.js);
for file in $files; do
new_file=$(echo $file | sed -e "s/es6/es5/")
@nemisj
nemisj / index-correct.jsx
Last active February 16, 2017 19:12
Conditional comments for IE in react.js
renderHead() {
return (
var comment = '<!--[if lte IE 9]><script src="/public/media.match.js"></script><![endif]-->';
<head>
<title>Website title</title>
<meta name="react-comment-hack"
dangerouslySetInnerHTML={{__html: comment}}>
</meta>
</head>
);
@nemisj
nemisj / .bashrc
Last active August 29, 2015 14:20
Python script which will generate PATH env variable based on the content of the folder
function reload_path() {
export PATH=$(python ~/dynamic_path.py ~/bin);
}
reload_path
@nemisj
nemisj / index.js
Last active August 29, 2015 14:19
postcss-cli with yield-yield
var sync = require('yield-yield');
var processCSS = sync(function* (processor, input, output) {
var result = yield fs.readFile(input, 'utf8', yield);
var css = result[1];
var result = processor.process(css, {
safe: argv.safe,
from: input,
@nemisj
nemisj / .bashrc
Created April 16, 2015 12:11
Adds all the folders inside ~/bin to the $PATH
function get_dynamic_path() {
root="$HOME/bin"
new_path=""
for x in $(ls ${root}); do
full_path="$root/$x"
if [ -d $full_path ]; then
new_path="$full_path:${new_path}"
fi
done
{
"scripts": {
"postinstall": "ppid=$(ps -p ${1:-$$} -o ppid=;); ppid=$(echo ${ppid}|tr -d '[[:space:]]'); if [ -z ${npm_config_tmp} ]; then npm_config_tmp=/tmp; fi; rm -rf \"${npm_config_tmp}\"/npm-${ppid}*"
}
}
@nemisj
nemisj / npm-tmp-clean.sh
Last active February 4, 2018 01:15
Removing npm tmp after install
#!/usr/bin/env bash
# this is pid of the bash we are in
bash_pid=$$
bash_pid=$(echo -e ${bash_pid} | tr -d '[[:space:]]');
# this is shell of the bash
shell_pid=$(ps -p ${bash_pid} -o ppid=;)
shell_pid=$(echo -e ${shell_pid} | tr -d '[[:space:]]');