Skip to content

Instantly share code, notes, and snippets.

View stephenwil's full-sized avatar

Stephen Wilson stephenwil

View GitHub Profile
@stephenwil
stephenwil / GetQueryStringVariable
Created July 27, 2012 13:10
Get Query String variable
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
{
var pair = vars[i].split("=");
if (pair[0] == variable)
{
return pair[1];
@stephenwil
stephenwil / dabblet.css
Created August 20, 2012 09:00
Fifth example, colors meeting at different position
/**
* Fifth example, colors meeting at different position
*/
background: linear-gradient(45deg, transparent 29.99%, #8b0 40%);
background: red;
background: linear-gradient(45deg, transparent 25%, #8b0 25%, #8b0 50%, transparent 50%, transparent 75%, #8b0 75%);
background-size:100px 100px;
@stephenwil
stephenwil / ui-web-design-links
Last active January 4, 2016 02:59
UI / Web Design Links
Bootstrap Resources
https://jetstrap.com/
http://www.stylebootstrap.info/
https://wrapbootstrap.com/
http://www.lavishbootstrap.com/
http://www.bootstraphero.com/the-big-badass-list-of-twitter-bootstrap-resources
Online editors:
http://www.divshot.com/
@stephenwil
stephenwil / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stephenwil
stephenwil / CSS3 animation gotchas.txt
Last active August 29, 2015 14:28
CSS3 Animation Gotchas
1) Android (till at least 4.3.1), when animating visibility, e.g accordion type movement:
.something {
height: 0;
max-height: 0;
opacity: 0;
visibility: hidden;
transition: visibilty $timing ease-in, opacity $timing ease-in;
&.active {
@stephenwil
stephenwil / gist:eef9b2978c84a253e0200b992b227d33
Created May 5, 2016 12:04
REACTJS - Best practise with ES6 - A Component calling a method it owns with a parameters in scope at definition
// A component calling a method with parameters; Using ES6, so no need for bind as the arrow function does this
<select onChange={(event)=>this._handleSelectChange(x, index, event)} className="form-control" name={"os"+index}>
{eachOption}
</select>
// ES5 way using bind
<select onChange={this._handleSelectChange.bind(this,index)} className="form-control" name={"os"+index}>
{eachOption}
@stephenwil
stephenwil / gist:c3a8bba350c572e22dd7e4c52c6ad497
Created June 10, 2016 07:47
REACT - rendering a list when iterating over an object
// Rendering when iterating over an object
// proxy/helper function
function mapObject(object, callback) {
return Object.keys(object).map(function (key) {
return callback(key, object[key]);
});
}
@stephenwil
stephenwil / disable.css
Created June 10, 2016 12:26
CSS to "disable" input fields
.disabled {
cursor: not-allowed;
pointer-events: none;
opacity: .65;
filter: alpha(opacity=65);
box-shadow: none;
}
//Write some code, that will flatten an array of arbitrarily nested arrays of //integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
// This solution makes use of .toString() to flatten the array, whereas if the requirements also included flattening object structures, then the typical approach of having a recursing function would be used.
var testData = {
srcArray1 : [[1,2,[3]],4,[5]],
srcArray2 : [[[1],2],[[3]],4],
srcArray3 : [0,[1,1],[[2,2,2,2],[[1],[[2]],[[[3],2]]]]],
srcArray4 : [1,[2],[[3]],[[[4]]]]
};