Skip to content

Instantly share code, notes, and snippets.

View magoz's full-sized avatar

Magoz magoz

View GitHub Profile
@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@kylerush
kylerush / full.js
Created January 8, 2012 21:23
JavaScript epoch time convert number prototype
Number.prototype.timeLeft = function(){
var days = Math.floor(this / 86400);
var hours = Math.floor((this - (days * 86400)) / 3600);
var minutes = Math.floor((this - ((hours * 3600) + (days * 86400))) / 60);
var seconds = this - ((days * 86400) + (hours * 3600) + (minutes * 60));
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@michail-nikolaev
michail-nikolaev / gist:3858501
Created October 9, 2012 12:24
Javascript - quarter start and end
var now = new Date();
var quarter = Math.floor((now.getMonth() / 3));
var firstDate = new Date(now.getFullYear(), quarter * 3, 1);
var endDate = new Date(firstDate.getFullYear(), firstDate.getMonth() + 3, 0);
@schamane
schamane / curl.js
Created February 23, 2013 09:47
Curl vs http module for nodejs
var exec = require('child_process').exec,
url = "http://google.com/",
timeout = "3",
data="?q=test";
var time = process.hrtime();
exec('curl --max-time ' + timeout + ' -d \'' + data + '\' ' + url, function (error, stdout, stderr) {
var diff = process.hrtime(time);
//console.log('stdout: ' + stdout);
//console.log('stderr: ' + stderr);
<?php
/**
* Sync Groups from WordPress to Discourse
*
* First creates 'groups' meta_key (which should be customized to your needs)
* Then it monitors for changes in the 'groups' meta_value and connects to Discourse API to sync groups
*
* WordPress References
* https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/meta.php?order=name#L235
* http://wordpress.stackexchange.com/questions/16835/how-to-hook-update-post-meta-and-delete-post-meta
@tuxfight3r
tuxfight3r / vim-shortcuts.md
Last active June 23, 2024 12:21
VIM SHORTCUTS

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
@dommmel
dommmel / invite_to_slack.js
Created May 25, 2016 14:40
Zapier Code to auto invite users to slack
var slackTeam = "YOUR_SLACK_TEAM_NAME ";
var token = 'YOUR_ADMIN_TEST_TOKEN';
// A test token will suffice.
// You can generate one at https://api.slack.com/docs/oauth-test-tokens
// Just make sure that the user issuing the test token is an admin.
var url = 'https://'+ slackTeam + '.slack.com/api/users.admin.invite';
fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@tutweb
tutweb / write-json-file.php
Created October 6, 2016 14:36
Write JSON file with PHP
<?php
// array
$array = Array (
"0" => Array (
"id" => "USR1",
"name" => "Steve Jobs",
"company" => "Apple"
),
"1" => Array (
"id" => "USR2",