Skip to content

Instantly share code, notes, and snippets.

View samnajian's full-sized avatar
Working from home

Sam Najian samnajian

Working from home
View GitHub Profile
samnajian / change-svg-fill-color.js
Created September 27, 2017 15:17
Trick to change svg fill color
View change-svg-fill-color.js
document.addEventListener('DOMContentLoaded', function() {
* Refrence to object element that has svg as data attribute
const obj = document.querySelector('object');
const svg = obj.contentDocument.querySelector("svg"); = "red" // change fill color to red
}, false);
samnajian / flatten_array.js
Last active July 18, 2016 08:09
Flattern array in JS
View flatten_array.js
function flatten_array( arr ){
* Checks if _arr is an array
* @param Array|Mixed _arr variable to check
* @return Bool whether _arr is an array
const is_array = ( _arr ) => {
return typeof _arr === "object" && typeof _arr.concat === "function";
View gist:58f15655d35c4cdb51ec
'post_image_variants' => '[{\"vid\":\"variant-1415709668089-1002\",\"label\":\"Full Center\",\"group\":{\"margin_left\":\"0\",\"margin_right\":\"0\",\"col\":\"18\",\"row\":\"54\",\"left\":\"0\",\"float\":\"none\",\"height\":\"270\",\"width_cls\":\"c18\",\"left_cls\":\"ml0\",\"clear_cls\":\"\"},\"image\":{\"order\":\"0\",\"col\":\"24\",\"top\":\"0\",\"left\":\"0\",\"row\":\"40\",\"clear\":\"true\",\"height\":\"200\",\"width_cls\":\"c24\",\"left_cls\":\"ml0\",\"clear_cls\":\"clr\",\"top_cls\":\"mt0\"},\"caption\":{\"show\":\"1\",\"order\":\"1\",\"col\":\"24\",\"top\":\"0\",\"left\":\"0\",\"row\":\"10\",\"clear\":\"true\",\"height\":\"50\",\"width_cls\":\"c24\",\"left_cls\":\"ml0\",\"clear_cls\":\"clr\",\"top_cls\":\"mt0\"}},{\"vid\":\"variant-1415709681741-1955\",\"label\":\"Full Left\",\"group\":{\"margin_left\":\"-3\",\"margin_right\":\"0\",\"col\":\"18\",\"row\":\"54\",\"left\":\"0\",\"float\":\"none\",\"height\":\"270\",\"width_cls\":\"c21\",\"left_cls\":\"ml0\",\"clear_cls\":\"\"},\"image\":{\"order\":\"0
View gist:ab7123225f081323b935
/*global ugalleries */
/* @ TODO: need to add [+] button and make sure it triggers the appropriate event..
//Adding [+] control
var $upfrontObjectContent = this.$el.find('.upfront-object-content');
if(this.$el.find('a.add-gallery-item').length < 1) {
$('<b class="upfront-entity_meta add_item upfront-ui"><a href="#" class="upfront-icon-button a.add-gallery-item add-item"></a></b>').insertBefore($upfrontObjectContent);
View gist:32c5299348014c590977
$header = upfront_create_region(
"name" => "header",
"title" => "Header",
"type" => "wide",
"scope" => "local",
"position" => 1,
"allow_sidebar" => true
View gist:efdf26d0153ab63982ed
$header = upfront_create_region(
"name" => "header",
"title" => "Header",
"type" => "wide",
"scope" => "local"
"row" => 24,
View gist:1fceb58d862aa041dbcc
<?php $typography = '{}';
$layout_style = '';
$theme_fonts = '';
$theme_colors = '';
$layout_properties = '[{\"name\":\"layout_style\",\"value\":\"#usearch #usearch-archive-search .upfront-object-content{\\n width:630px;\\n}\\{\\n width:530px;\\n height:50px;\\n float:left;\\n padding:0;\\n border:none;\\n line-height:50px;\\n padding-left:22px;\\n}\\{\\n float:left;\\n border:none;\\n height:50px;\\n width:50px;\\n width:;\\n text-indent:9999px;\\n overflow:hidden;\\n\\n}\"}]';
View gist:54264acf37a12855ad8e
<?php $typography = '{}';
$layout_style = '#usearch #usearch-archive-search .upfront-object-content{
View gist:b8e0ea817331e5b56d33
include_once get_template_directory() . '/library/class_upfront_debug.php';
include_once get_template_directory() . '/library/class_upfront_server.php';
include_once get_template_directory() . '/library/class_upfront_theme.php';
class Uf_fixer extends Upfront_ChildTheme {
public function initialize() {
samnajian /
Created December 18, 2013 21:50 — forked from jookyboi/
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.


  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage