Skip to content

Instantly share code, notes, and snippets.

View minmaxdata's full-sized avatar
🐕

Ke McAdams minmaxdata

🐕
  • DTN
  • Seattle, WA
View GitHub Profile
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@madoke
madoke / XSSRequestWrapper.java
Created April 9, 2012 22:23 — forked from ulinkwo/XSSRequestWrapper.java
Stronger Anti Cross-Site Scripting (XSS) Filter for Java Web Apps
package pt.impresa.iweb.filters.request;
import java.io.IOException;
import java.text.Normalizer;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@blin86
blin86 / promise-sample.js
Last active December 11, 2016 14:41
Constructing and using an AngularJS promise
angular.module('app', [])
.factory('FakeAmazonService', function($http, $q) {
return {
validateShippingAdddress: function(address) {
var deferred = $q.defer();
$http.post('/api/address/validate', address)
.then(function(resp) {
deferred.resolve({ success: true, data: resp});
}),
function(error) {
@danielstocks
danielstocks / gist:5da83982d3b4c7b503a0
Created October 17, 2014 11:38
Pretty print a JavaScript Tree Data Structure
// Example implementation: http://jsfiddle.net/2f7w2fpn/
var indent = 1;
function walk(tree) {
tree.forEach(function(node) {
console.log('--' + Array(indent).join('--'), node.key);
if(node.children) {
indent ++;
walk(node.children);
}
@PurpleBooth
PurpleBooth / README-Template.md
Last active June 30, 2024 00:35
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@spences10
spences10 / github-cheat-sheet.md
Last active March 22, 2022 17:59
GitHub Cheat Sheet

Useful Git commands

This is just stuff that I have put down that I find I use a lot of the time for my own reference.

Latest changes from repo to your machine

$ git pull
@kiok46
kiok46 / redux_setup.md
Last active February 15, 2021 01:02
Redux, store, actions and reducers setup along with explanation.

Redux Setup

Implementation of redux inside any react.js or react-native application,

  • we will create an instance of the redux store.
  • We are going to create a provider tag from react redux library
  • Then render that provider tag passing in the store as a prop, then any child component to this provider tag will have access to this store through the context system inside of react.
  • import { Provider } from ‘react-redux’; // In main.js
  • to create a store create one in a separate folder.
@iHani
iHani / arrayMethods.js
Last active August 6, 2018 20:10
Example of array methods: forEach, map, filter, some, every, indexOf, and include. (ES2015 syntax)
/*
* forEach
*/
// forEach is very simlar to for-looping arr.length
// array.forEach(callback, context)
var arr = ['apple', 'orange', 'watermelon', 10, 20, 30]
arr.forEach((value, index) => console.log(`Element's ${index} type is ${typeof value}`))
// Prints:
// Element 0 type is string
@iHani
iHani / classes.js
Last active August 6, 2018 20:10
Example of classes in JavaScript ES2015
class Person {
constructor(name = 'Anonymous', age = 0) {
this.name = name
this.age = age
}
getGreeting(){
return `Hi, I am ${this.name}`
}
getDescription(){
return `${this.name} is ${this.age} years old`