Skip to content

Instantly share code, notes, and snippets.

@basiclines
basiclines / figma_hooks_slack.js
Created January 11, 2021 16:59
AWS lambda for sending Slack messages from Figma Hooks API
const https = require('https');
const querystring = require('querystring');
/**
* Pass the data to send as `event.data`, and the request options as
* `event.options`. For more information see the HTTPS module documentation
* at https://nodejs.org/api/https.html.
*
* Will succeed with the response body.
*/
@jenil
jenil / figma-process-webhook.js
Last active April 23, 2021 09:17
Figma webhook to Slack notifications
const https = require("https");
exports.handler = (req, ctx, callback) => {
const event = JSON.parse(req.body);
console.log("Event:", event);
let response = {
statusCode: 200,
body: "ok"
};
@matsadler
matsadler / test.html
Created September 27, 2017 19:23
Javascript to apply a colour tint to an image
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="tint.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll("img").forEach(function (img) {
img.addEventListener("load", function () {
tint(img);
@mollerse
mollerse / gulpfile-express.js
Last active March 28, 2021 20:07
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
function graph(data, w, h, color) {
var canvas = document.createElement('canvas');
var max = Number.MIN_VALUE;
// normalize
var len = data.length, i;
for(i = 0; i < len; ++i) {
max = Math.max(data[i], max);
}
for(i = 0; i < len; ++i) {
@fcrespo82
fcrespo82 / gist:4137305
Created November 23, 2012 21:01
Script to sync Pythonista App to Dropbox
import webbrowser, os, pprint
# Include the Dropbox SDK libraries
#from dropbox import client, rest, session
import dropbox
# Configuration
TOKEN_FILENAME = 'PythonistaDropbox.token'
# Get your app key and secret from the Dropbox developer website
APP_KEY = '<your dropbox app_key>'
APP_SECRET = '<your dropbox app_secret>'
@gazpachoking
gazpachoking / set_torrent_comment.py
Created November 13, 2012 18:48
Plugin to set the comment in a torrent
import logging
from flexget.plugin import priority, register_plugin
from flexget.utils.template import RenderError
log = logging.getLogger('set_torrent_comment')
class SetTorrentComment(object):
"""
Changes comment in torrent file
@wrenoud
wrenoud / DropboxSync.py
Created November 10, 2012 02:46
DropboxSync
import os
import sys
import pickle
import console
# I moved 'dropboxlogin' into a sub folder so it doesn't clutter my main folder
sys.path += [os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib')]
import dropboxlogin # this code can be found here https://gist.github.com/4034526
STATE_FILE = '.dropbox_state'
@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

#!/bin/bash
# Upgrade to rspec-rails 2.2.2
# response.headers["Status"].should == "201 Created" does not work any more
# response.status.should == "201 Created" does work now
#
# find all controllers specs which contains response.headers["Status"].should
# sort them
# and remove duplications
for c in `grep 'Status' -r spec/controllers | grep 'response.headers' | cut -d':' -f1 | sort | uniq`