Skip to content

Instantly share code, notes, and snippets.

View lawwantsin's full-sized avatar
🏠
Working from home

Lawrence Whiteside lawwantsin

🏠
Working from home
View GitHub Profile
@lawwantsin
lawwantsin / flatten.js
Created November 26, 2017 18:17
Recursive Array Flattener
// Recursive function that loops through each array, adding it's contents to the original until we're out of numbers.
const flatten = (integersArray, previousArray) => {
// First time it's called there is no second argument, so make that an empty array.
const newArray = previousArray || []
// integersArray needs elements or just return previous and exit recursion.
if (integersArray && integersArray.length > 0) {
integersArray.forEach(i => {
// if it's an integer, add it to the returned array.
if (typeof i === "number") {
newArray.push(i)
var flatten = function(integers_array, flatten_array) {
// If this function is called in recursion mode, then we
// need to keep previous recursion results.
var all_results = flatten_array || [];
// We just want to perform any action if there's a
// valid array input and this array contains any value in it.
if (integers_array && integers_array.length > 0) {
integers_array.forEach(function(value) {
if (typeof value === 'number') {

TodoMVC React

SCSS Style Guide

###File Structure

This is an example of a component named quote.

app/assets/stylesheets/
├── application.scss
@lawwantsin
lawwantsin / custom_file_store.rb
Created October 31, 2015 04:35 — forked from bradpauly/custom_file_store.rb
simple file store for rails sessions
module ActionDispatch
module Session
class CustomFileStore < ActionDispatch::Session::AbstractStore
def get_session(env, session_id)
session_data = {}
session_id ||= generate_sid
File.open(tmp_file(session_id),'r') do |f|
data = f.read
session_data = ::Marshal.load(data) unless data.empty?
end rescue nil
@lawwantsin
lawwantsin / fbwallfix.js
Created June 6, 2011 04:31
Fix for Neosmart's fbWall JQuery Plugin.
/*
Fix for Neosmart's fbWall JQuery Plugin.
http://www.neosmart.de/social-media/facebook-wall
after facebook required an access token. Stated here.
http://developers.facebook.com/blog/post/510
Hope everyone at home can follow along.
*/
// Using the Javascript SDK, you get login status. Works with FB.login() this same way.
@lawwantsin
lawwantsin / designer.html
Last active August 29, 2015 14:15
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../topeka-elements/avatars.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icons/core-icons.html">