Skip to content

Instantly share code, notes, and snippets.

View rtanglao's full-sized avatar
😃
you rock :-)

Roland Tanglao rtanglao

😃
you rock :-)
View GitHub Profile
@sintaxi
sintaxi / thing.js
Last active July 9, 2016 22:00
A JavaScript question. What is the best way to handle this situation?
var expensiveThing = function(callback){
setTimeout(function(){
callback(null, { name: "Thurston Moore" })
}, 5000)
}
var fetchAndLogExpensiveThing = function(){
expensiveThing(function(err, data){
console.log(err, data)
@russellbeattie
russellbeattie / search-apple-mail-body.js
Created June 1, 2016 01:11
Searches Apple mail Inbox for your name (if your name is Russ - otherwise change that bit) in the latest message and logs out/marks yellow.
#!/usr/bin/env osascript -l JavaScript
function run(argv) {
var Mail = new Application("Mail");
var inbox = Mail.inbox();
var messages = inbox.messages();
@rnewman
rnewman / bookmark-sync-1.md
Last active December 2, 2017 00:48
Bookmark Sync 1

Designing bookmark sync… again

For the second time, I'm building an implementation of bookmark sync on a new platform. The last one, in early 2012, was Firefox for Android. That turned out relatively well, considering the circumstances, but it didn't go far enough in avoiding some ancient errors baked into the desktop codebase.

For Firefox on iOS we have a new set of platform constraints and a strong desire to avoid some of the known pitfalls. This post sets out some of the considerations. A future post will set out the proposed solution.

Our goal: keep a tree of bookmarks in sync across multiple devices.

Syncs occur to and from a server. Devices don't communicate directly.

@skeskali
skeskali / weather.rb
Created June 5, 2015 15:44
Skillcrush 104 Ruby Blueprint - Create a Weather App.
require 'yahoo_weatherman'
# get current location from user
def getLocation
puts "What is your location? Please enter city or postal code."
location = gets.chomp
end
# get current location from Yahoo Weatherman gem by looking it up
@scripting
scripting / sendToSlack.js
Last active July 9, 2022 13:03
A tiny JavaScript app that sends a message to your default Slack channel. Can be customized with a name, icon, emoji or sent to a different channel. Runs in Node.js.
var request = require ("request");
var urlWebHook = "https://hooks.slack.com/services/abcdef"; //the URL you get on your "incoming web hooks" page.
function sendToSlack (s, theUsername, theIconUrl, theIconEmoji, theChannel) {
var payload = {
text: s
};
if (theUsername !== undefined) {
payload.username = theUsername;
@johnbaums
johnbaums / iwanthue.R
Last active June 7, 2020 22:48
Palettes of distinct colours, generated through kmeans clustering of LAB colour space
swatch <- function(x) {
# x: a vector of colours (hex, numeric, or string)
par(mai=c(0.2, max(strwidth(x, "inch") + 0.4, na.rm = TRUE), 0.2, 0.4))
barplot(rep(1, length(x)), col=rev(x), space = 0.1, axes=FALSE,
names.arg=rev(x), cex.names=0.8, horiz=T, las=1)
}
# Example:
# swatch(colours()[1:10])
# swatch(iwanthue(5))
@scripting
scripting / correctedStatusMedia
Created July 1, 2014 14:13
Updated code snippet for a Scripting News blog post, with corrected code
//Goes with this blog post -- http://scripting.com/2014/07/01/twitterApiUpdatewithmedia.html#aIJWTS
var params = {
url: "https://api.twitter.com/1.1/statuses/update_with_media.json",
oauth: {
consumer_key: process.env.twitterConsumerKey,
consumer_secret: process.env.twitterConsumerSecret,
token: parsedUrl.query.oauth_token,
token_secret: parsedUrl.query.oauth_token_secret
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@atopal
atopal / gist:9272359
Last active August 29, 2015 13:56
A list of all English KB documents by product
SELECT `wiki_document`.`id`, group_concat(DISTINCT `products_product`.`title` SEPARATOR ', ') as 'products', group_concat(DISTINCT `products_topic`.`title` SEPARATOR ', ') as 'topics', `wiki_document`.`title`, `wiki_revision`.`created` as 'last updated'
FROM `wiki_document`
JOIN `wiki_document_products` ON `wiki_document_products`.`document_id` = `wiki_document`.`id`
JOIN `wiki_document_topics` ON `wiki_document_topics`.`document_id` = `wiki_document`.`id`
JOIN `wiki_revision` ON `wiki_revision`.`id`= `wiki_document`.`current_revision_id`
JOIN `products_product` ON `products_product`.`id` = `wiki_document_products`.`product_id`
JOIN `products_topic` ON `products_topic`.`id` = `wiki_document_topics`.`topic_id`
WHERE `wiki_document`.`locale` = "en-US"
GROUP BY `wiki_document`.`id`
@BashedCrab
BashedCrab / JumpyOctopus.py
Created February 12, 2014 03:25
JumpyOctopus
from scene import *
from PIL import Image
import sound
import random
GAME_READY = 0
GAME_PLAY = 1
GAME_DYING = 2
GAME_DEAD = 3