Skip to content

Instantly share code, notes, and snippets.

@wutangpaul
wutangpaul / gist:5442889
Created April 23, 2013 11:38
Conditional polyfill for media queries in older IE
<head>
<!-- Your head content -->
<link rel="stylesheet" href=style.css">
<!--[if lt IE 9]> <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.1.0/respond.min.js"></script> <![endif]-->
</head>
@wutangpaul
wutangpaul / Object Flatten
Last active April 26, 2016 13:34 — forked from penguinboy/Object Flatten
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) { continue; }
if ((typeof ob[i]) === 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) { continue; }
@wutangpaul
wutangpaul / Vagrantfile
Created August 31, 2016 13:34
Vagrant box with Ubuntu 14.04 + Go
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-14.04"
config.vm.provision :shell, :path => "provision.sh", privileged: false
config.vm.network "forwarded_port", guest: 8080, host: 8080
end
@wutangpaul
wutangpaul / commands.md
Last active March 15, 2017 14:43
Useful git commands

Create a new local git repository in current directory

git init

Check out (and switch to) remote branch

git checkout <remote branch name>

Update current branch

@wutangpaul
wutangpaul / gist:80ad318079bd62ff4b2abe4df76ee88c
Created October 26, 2017 09:52
Data row loop - Angular vs React
// Angular 1.x
<tr ng-repeat="friend in friends">
<td>{friend.name}</td>
</tr>
// React/JSX
{this.props.friends.map(function(friend) {
return (
<tr key={friend.guid}>
<td> {friend.name} </td>
@wutangpaul
wutangpaul / provision.sh
Created August 13, 2015 09:11
Quickly provision a Vagrant box with Ubuntu, nvm, Node.js, rvm, Ruby 2, mongodb and git.
#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y git-core subversion curl mongodb-org
@wutangpaul
wutangpaul / .eslintrc.js
Created August 27, 2019 08:15
My eslint/Airbnb setup to work with out of the box Prettier
module.exports = {
env: {
commonjs: true,
es6: true,
node: true
},
extends: "airbnb-base",
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly"
@wutangpaul
wutangpaul / App.js
Created January 15, 2020 23:34
styled components child hover
import React from "react";
import styled from "styled-components";
const NavBar = styled.div`
background-color: cornflowerblue;
padding: 1rem;
`;
const FlyoutMenu = styled.div`
background-color: limegreen;
@wutangpaul
wutangpaul / foo.sh
Created June 23, 2020 20:58
Enable syntax highlighting for all the things in nano
find /usr/share/nano/ -iname "*.nanorc" -exec echo include {} \; >> ~/.nanorc
@wutangpaul
wutangpaul / split_csv.sh
Created April 13, 2021 14:18
Split a large CSV file into smaller files
#!/bin/bash
FILENAME=orders.csv
HDR=$(head -1 $FILENAME)
split -l 5000 $FILENAME xyz
n=1
for f in xyz*
do
if [ $n -gt 1 ]; then
echo $HDR > Part${n}-$FILENAME
fi