Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
@nijikokun
nijikokun / about.md
Last active August 29, 2015 13:55
Javascript parallelization explained using cars and roads, because people have a hard time understanding things.

Road.js

Parallelization made easy in JavaScript / Node.js

Usage

var road = new Road();

road.onClear(function (error, results) { 
@martinklepsch
martinklepsch / config.fish
Created February 19, 2013 23:04
Add information about the git repository you're in to Fish shell's prompt
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
# Status Chars
set __fish_git_prompt_char_dirtystate '⚡'
set __fish_git_prompt_char_stagedstate '→'
set __fish_git_prompt_char_stashstate '↩'
@4E71
4E71 / concurrent.go
Created September 17, 2012 19:11
GoLang: Concurrency example
// Concurrent.go
// Simple example that demonstrates usage of Go routines.
package main
import (
"fmt"
"time"
"math/rand"
)
@montanaflynn
montanaflynn / colors.md
Last active December 10, 2016 21:21
ANSI color escape codes

Foreground

  • FgBlack = "\033[30m"
  • FgRed = "\033[31m"
  • FgGreen = "\033[32m"
  • FgYellow = "\033[33m"
  • FgBlue = "\033[34m"
  • FgMagenta = "\033[35m"
  • FgCyan = "\033[36m"
  • FgWhite = "\033[37m"
@kmonsoor
kmonsoor / getBrowser.js
Created January 18, 2017 10:25
Get Browser's name and it's version number ...
function getBrowser() {
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName = navigator.appName;
var fullVersion = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;
// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset = nAgt.indexOf("Opera")) != -1) {
@TooTallNate
TooTallNate / starwars.js
Created May 9, 2014 17:38
A little script to play the ASCII Star Wars, but with a hidden cursor, since over `telnet(1)` the cursor remains visible which is annoying
#!/usr/bin/env node
/**
* A little script to play the ASCII Star Wars, but with a hidden cursor,
* since over `telnet(1)` the cursor remains visible which is annoying.
*/
process.title = 'starwars'
var net = require('net')
@plugnburn
plugnburn / README.md
Last active June 1, 2018 21:42
XT.js - DOM construction / templating library in 18 lines of JS, 323 bytes minified

XT.js

Let's close the ultra-small library cycle with some awesome array-based templating. 323 bytes minified.

How to obtain

Just download the minified version here or include it into your code:

@subnetmarco
subnetmarco / CorsRequest.js
Last active July 10, 2018 09:03
Sample code for executing an AJAX request using jQuery.
$.ajax({
url: 'MASHAPE-URL', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
type: 'POST', // The HTTP Method
data: {}, // Additional parameters here
dataType: 'json',
success: function(data) { alert(JSON.stringify(data)); },
error: function(err) { alert(err); },
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "YOUR-MASHAPE-KEY"); // Enter here your Mashape key
}
anonymous
anonymous / enter_info.html
Created March 16, 2016 02:21
anonymously share salary
<!DOCTYPE html>
<head>
<title>salary: submit info</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/base-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding: 1em;
}
@jakoblorz
jakoblorz / README.md
Created May 17, 2019 16:22
Simple global state without depending on any additonal state manager. Uses and exposes React Hooks.

I used this structure in multiple projects and had a blast using it which is why I want to share it. It automatically propagates state changes to all dependent states and does not require additional state managing packages such as redux or mobx.

It enables architectures where e.g. the navbar is at the same level as all other components while still receiving updates about e.g. current user: If in this example the Index View logs the user in, there will also be a re-render in the navbar as its state has changed. This construction removes the state-silos of each component. Using useState instead of useReflectedState still enables the usage of component-specific state.

import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Route } from "react-router-dom";

import Navbar from "./views/Navbar";
import Index from "./views/Index";