Skip to content

Instantly share code, notes, and snippets.

Jim Wharton nobleach

Block or report user

Report or block nobleach

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nobleach
nobleach / beerSong.ml
Created Feb 12, 2018
Bottles of Beer
View beerSong.ml
let bottles = function
| 0 -> "no more bottles"
| 1 -> "1 bottle"
| n -> Printf.sprintf "%d bottles" n;;
let rec sing n =
let current = bottles n in
let next = bottles (n-1) in
Printf.printf
"%s of beer on the wall, %s of beer.\n"
@nobleach
nobleach / main.rs
Last active Jan 23, 2018
Reverse a string in Rust
View main.rs
extern crate regex;
use regex::Regex;
fn main() {
let sentence = "We're all dorks!";
println!("{}", reverse_string(sentence).to_string());
}
fn reverse_string(string: &str) -> String {
View critical path css
var critical = /(?!\.critical).*\.less$/;
// matches
Title.critical.less
// but not
Toast.less
App.less
var nonCritical = /^((?!critical).)*\.less$/gm;
View Promise and Fetch polyfills
// Add promise support for browser not supporting it
import es6Promise from 'es6-promise';
es6Promise.polyfill();
import fetch from 'isomorphic-fetch';
// or use axios
import axios from 'axios';
View node-setup.js
'use strict';
global.nodeMocha = true;
var chai = require('chai');
var sinon = require('sinon');
var sinonChai = require('sinon-chai');
var chaiJq = require('chai-jq');
chai.use(sinonChai);
View erik-challenge.js
var data = [['B1','B2','B3'],[1,2,3],[4,5,6],[7,8,9]];
// this would normally be provided by some sort of functional lib (or in a real functional language)
function zipObject(keys, vals) {
var zip = {};
keys.forEach(function(k,i) {zip[k] = vals[i];});
return zip;
}
function car(arr) {
View erik-challenge.js
var data = [['B1','B2','B3'],[1,2,3],[4,5,6],[7,8,9]];
// this would normally be provided by some sort of functional lib (or in a real functional language)
function zipObject(keys, vals) {
var zip = {};
keys.forEach(function(k,i) {zip[k] = vals[i];});
return zip;
}
function generateWantedData(columnNames, ...data) {
View FizzBuzz
for (var i = 1; i <= 100; i++) {
var x = '';
if(i%3===0) x += 'Fizz';
if(i%5===0) x += 'Buzz';
console.log(x=='' ? i : x);
}
@nobleach
nobleach / fading text
Created Dec 18, 2014
Fading Text instead of ellipses
View fading text
.post.grid .description {
margin-top: 15px;
font-weight: 400;
font-size: 14px;
line-height: 19px;
overflow: hidden;
position: relative;
max-height: 57px;
}
.post.grid .description:after {
View gist:c7e2e3a23fe88cb95dd4
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
fg
zle redisplay
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
You can’t perform that action at this time.