This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port module Training exposing (..) | |
import Html exposing (..) | |
import Html.App exposing (programWithFlags) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Html.Keyed as Keyed | |
import Html.Lazy exposing (lazy, lazy2) | |
import Json.Decode as Json | |
import String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ul = document.getElementsByClassName('thumbs')[0] | |
var toDelete = [] | |
for (var i = 0; i < ul.children.length; i++) { | |
var releaseDate = ul.children[i].getElementsByClassName('now-thumbnail')[0].getAttribute('data-releasedate') | |
if (+releaseDate < 2000) toDelete.push(ul.children[i]) | |
} | |
toDelete.forEach(function (el) {el.parentNode.removeChild(el)}) | |
for (var i = ul.children.length; i >= 0; i--) { | |
ul.appendChild(ul.children[Math.random() * i | 0]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// price = price * 100 for simplicity | |
var str = '' | |
for (let price = 1; price <= 400; price++) { | |
let gallons = 1 | |
while (gallons*price % 100 !== 0) | |
gallons++ | |
str+=format(price, gallons, gallons*price) | |
} | |
function format(gasPrice, totalGallons, totalPrice) { | |
return padRight(`Gas Price: ${currency(gasPrice)}`, ' ', 22) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import { render } from 'react-dom' | |
import Gun from 'gun' | |
const gun = Gun().get('todos') | |
const formatTodos = todos => Object.keys(todos) | |
.map(key => ({ key, val: todos[key] })) | |
.filter(t => Boolean(t.val) && t.key !== '_') | |
class Todos extends Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const http = require('http') | |
const Gun = require('gun') | |
const app = express() | |
const server = http.createServer(app) | |
Gun({file: 'data.json', web: app}) | |
app.use(Gun.serve) | |
app.get('/', function (req, res) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# total lines removed | |
git log --numstat --pretty="" | grep -v lock | sed -r -e "s/^([0-9]+)\\s+([0-9]+).*/\2/" | grep -v "^-" | paste -sd+ | bc | |
# total lines added | |
git log --numstat --pretty="" | grep -v lock | sed -r -e "s/^([0-9]+)\\s+([0-9]+).*/\2/" | grep -v "^-" | paste -sd+ | bc | |
# the main thing to edit would be git log. You could change this to whatever author you like or over | |
# whatever time frame or between two commits, etc. The `grep -v lock` removes all files like yarn.lock | |
# or package-lock.json, which is the main reason I created this command, because those files added like 40,000 | |
# line changes to my code. Also the `grep -v "^-"`removes `png` files and such that are not countedl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# force kill process by port | |
# Usage: "force-kill PORT" | |
sudo netstat -tulnp | grep "$1" | sed -r -e "s/.*LISTEN\\s+([0-9]+).*/\1/" | xargs sudo kill -9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
Fetch(url string) (body string, urls []string, err error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PY2_CONFIG_DIR=$(sudo find /usr/lib -type d -regex ".*python2.[0-9]/config[^/]*") | |
PY3_CONFIG_DIR=$(sudo find /usr/lib -type d -regex ".*python3.[0-9]/config[^/]*") | |
if ( [ -d "$PY2_CONFIG_DIR" ] || [ -d "$PY3_CONFIG_DIR" ] ) ; then | |
py2_arg="--with-python-config-dir=$PY2_CONFIG_DIR" | |
py3_arg="--with-python3-config-dir=$PY3_CONFIG_DIR" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your key bindings in this file to override the defaults | |
[ | |
{ | |
"key": "ctrl+`", | |
"command": "workbench.action.terminal.focus", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "ctrl+`", | |
"command": "workbench.action.focusActiveEditorGroup", |