Skip to content

Instantly share code, notes, and snippets.

View r3nya's full-sized avatar
☮️
¯\_(ツ)_/¯

Andrew M. r3nya

☮️
¯\_(ツ)_/¯
View GitHub Profile
@r3nya
r3nya / useClassnames.js
Created May 30, 2017 22:49 — forked from matthewoden/useClassnames.js
Dynamic classnames for react and react native.
/*
This is a real simple pattern that allows you to
maintain a syntax similar to classnames, but use
CSS Module mode in webpack.
(solving the problem of cleanly using object properies as keys)
*/
function use(result, conditions){
/*
var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@r3nya
r3nya / pre-commit.sh
Created November 18, 2016 14:22 — forked from dahjelle/pre-commit.sh
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done
@r3nya
r3nya / README.md
Created September 27, 2016 18:34 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@r3nya
r3nya / gulpfile.js
Created December 22, 2015 10:31 — forked from c01nd01r/gulpfile.js
Gulp build error to browser
//npm i gulp gulp-stylus gulp-plumber browser-sync bs-fullscreen-message
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync').create();
//Enable "Fullscreen Messages" plugin in Browsersync Plugins web settings (http://localhost:3001/plugins)
//Notification template
var bsError = function(data) {

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/usr/bin/env sh
tweetbot_running() {
ps x | grep -v grep | grep Tweetbot > /dev/null
}
clean_tweetbot_cache() {
rm -rf ~/Library/Containers/com.tapbots.TweetbotMac/Data/Library/Caches/com.tapbots.TweetbotMac
}
// to get the current latitude and longitude from browser
// credits https://github.com/arunisrael/angularjs-geolocation
'use strict';
angular.module('geolocation',[]).constant('geolocation_msgs', {
'errors.location.unsupportedBrowser':'Browser does not support location services',
'errors.location.notFound':'Unable to determine your location',
});
angular.module('geolocation')
@r3nya
r3nya / openvpn.md
Last active August 29, 2015 14:10 — forked from padde/openvpn.md

OpenVPN on Ubuntu 12.10 at DigitalOcean

Install OpenVPN

sudo apt-get install openvpn

Generate Server Certificates

sudo cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/openvpn/easy-rsa2

cd /etc/openvpn/easy-rsa2

@r3nya
r3nya / nodejs
Last active August 29, 2015 14:09
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"