Skip to content

Instantly share code, notes, and snippets.

@jagmitg
jagmitg / debounce.js
Created April 26, 2018 12:45 — forked from pbojinov/debounce.js
Debounce
// http://davidwalsh.name/function-debounce
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
@jagmitg
jagmitg / Jitouch-Restarter
Created April 13, 2018 13:03 — forked from onevcat/Jitouch-Restarter
This gist kill Jitouch and then restart it. It solves problems when using Jitouch with Magic Trackpad 2
pkill -f "Jitouch"
sleep 5
nohup ~/Library/PreferencePanes/Jitouch.prefPane/Contents/Resources/Jitouch.app/Contents/MacOS/Jitouch > /dev/null 2>&1 &
@jagmitg
jagmitg / pubsub.js
Created December 29, 2017 23:08 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@jagmitg
jagmitg / gist:83b0827bb8f766369f863bd175f97f24
Created August 23, 2017 18:51 — forked from Sam152/gist:8413834
Functions that are no longer in D8.
actions_actions_map is no longer in D8.
actions_delete is no longer in D8.
actions_do is no longer in D8.
actions_function_lookup is no longer in D8.
actions_get_all_actions is no longer in D8.
actions_list is no longer in D8.
actions_load is no longer in D8.
actions_save is no longer in D8.
actions_synchronize is no longer in D8.
aggregator_admin_form is no longer in D8.
@jagmitg
jagmitg / __INDEX.txt
Created September 14, 2016 12:15 — forked from facine/__INDEX.txt
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@jagmitg
jagmitg / Drupal 8 rebuild
Created September 12, 2016 23:11 — forked from tsphethean/Drupal 8 rebuild
Rebuild a drupal 8 site after fresh pull from git.
#!/bin/sh
# Drop old DB
mysql -uroot -e "DROP DATABASE drupal8"
# Create new DB
mysqladmin -uroot create drupal8
# Add permissions
mysql -uroot -e "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON drupal8.* TO 'drupal8'@'localhost' IDENTIFIED BY 'password'"
# Tidy up site files
@jagmitg
jagmitg / ImageRenderExampleBlockResponsive.php
Created July 12, 2016 15:42 — forked from jerbob92/ImageRenderExampleBlockResponsive.php
Render responsive image into a block Drupal 8 Example
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlockResponsive.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
@jagmitg
jagmitg / ImageRenderExampleBlockByURI.php
Created July 12, 2016 15:42 — forked from jerbob92/ImageRenderExampleBlockByURI.php
Render image into a block Drupal 8 Example by URI
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlockByURI.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
@jagmitg
jagmitg / ImageRenderExampleBlock.php
Created July 12, 2016 15:42 — forked from jerbob92/ImageRenderExampleBlock.php
Render image into a block Drupal 8 Example
<?php
/**
* @file
* Contains Drupal\mymodule\Plugin\Block\ImageRenderExampleBlock.
*/
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
<track kind="subtitles | captions | descriptions" src="path/to/file.vtt" srclang="" label="">