Skip to content

Instantly share code, notes, and snippets.

View TimoSolo's full-sized avatar

Timothy Solomon TimoSolo

View GitHub Profile
@keegancsmith
keegancsmith / github-push-pr
Created October 27, 2017 09:22
git alias to push and open PR view
#!/bin/bash
# Pushes to origin and opens a github compare view of it to speed up PR
# creation.
#
# To install add to $PATH with executable permission and run
#
# git config --global alias.pr '!github-push-pr'
#
@sikanhe
sikanhe / improved_cache.js
Last active November 20, 2017 21:45
Most efficient way to store domain state in Redux (Indexed Key-Value Store)
//After working on the backend for a while, I started to continue working on my front end,
//I revisited my redux “cache” store and I made this improvement that made my life a lot easier.
//In my project for example, some collections i need to get the document by id, some by slug, some by username, and etc.
//If I need to account for those cases I had to make new action creators/types, for different entities.
//This is very frustrating as it makes the code less dry and leads to more boilerplate.
//Then what I realized was, I can just pass a “index” option for my insert action creators!(which defaults to “id")
//Actions
@kharissulistiyo
kharissulistiyo / functions.php
Created November 27, 2015 12:36
WooCommerce: Display all products in one page in a simple way
<?php
/**
* All products in one page
*
* Display all products in a table with their add to cart button.
* Usage : [all_products] to display all products.
* Usage : [all_products category="singles"] to display products under "singles" category (slug).
*/
@scottmagdalein
scottmagdalein / clickable-element.html
Last active March 15, 2023 18:01
Make the Mailchimp Subscriber popup appear on click
<!-- This is the HTML element that, when clicked, will cause the popup to appear. -->
<button id="open-popup">Subscribe to our mailing list</button>
@timgit
timgit / megaNumber.js
Last active January 15, 2020 08:35
Large number format filter for Angular written in ES6 that rounds to the specified decimal place (defaults to 1). 1 billion => 1B, 1,490,000 => 1.5M, 999,999 => 1M
angular.module('utilsModule').filter("megaNumber", () => {
return (number, fractionSize) => {
if(number === null) return null;
if(number === 0) return "0";
if(!fractionSize || fractionSize < 0)
fractionSize = 1;
var abs = Math.abs(number);
@danawoodman
danawoodman / 0-react-hello-world.md
Last active March 9, 2024 00:32
React Hello World Examples

React "Hello World" Examples

Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.

They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).

Usage

You will want to create an index.html file and copy/paste the contents of 1-base.html and then create a scripts.js file and copy/paste the contents of one of the examples into it.

@juanmav
juanmav / gist:2f11b53b2bf65ac8f0a4
Created October 3, 2014 21:51
PersistenceJs Example with AngularJS Factory.
// Task.js
var app = angular.module('MyApp');
app.factory('Task', function () {
// Hacer un ejeemplo con t odo para depues re-factorizar.
//console.debug(persistence.store.websql);
persistence.store.websql.config(persistence, 'MyTask', 'A database description', 5 * 1024 * 1024);
var Task = persistence.define('Task', {
name: "TEXT",
@jgoux
jgoux / app.js
Created April 15, 2014 14:53
Ionic / AngularJS service wrapper for Web SQL API / SQLite-Cordova-Plugin
angular.module('myApp', ['ionic', 'myApp.services', 'myApp.controllers'])
.run(function(DB) {
DB.init();
});
@samhemelryk
samhemelryk / pre-commit
Last active May 27, 2021 05:41
A git pre-commit hook example.
#!/bin/bash
#
# This pre-commit hook checks that you havn't left and DONOTCOMMIT tokens in
# your code when you go to commit.
#
# To use this script copy it to .git/hooks/pre-commit and make it executable.
#
# This is provided just as an example of how to use a pre-commit hook to
# catch nasties in your code.
@revskill10
revskill10 / lopmonhoc.js.jsx
Created January 22, 2014 09:25
Integrate Datatable with React.js
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){