Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Lawrence Whiteside lawwantsin

🏠
Working from home
View GitHub Profile
@lawwantsin
lawwantsin / flatten.js
Created Nov 26, 2017
Recursive Array Flattener
View flatten.js
// 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)
View gist:9e654ea719a2780b66eafee721ab04c3
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') {
View 1. SCSS Style Guide.markdown

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 Oct 31, 2015 — forked from bradpauly/custom_file_store.rb
simple file store for rails sessions
View custom_file_store.rb
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
View designer.html
<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">
@lawwantsin
lawwantsin / fbwallfix.js
Created Jun 6, 2011
Fix for Neosmart's fbWall JQuery Plugin.
View fbwallfix.js
/*
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.