Skip to content

Instantly share code, notes, and snippets.

View jpsilvashy's full-sized avatar
🎯
Focusing

JP Silvashy jpsilvashy

🎯
Focusing
View GitHub Profile
@jpsilvashy
jpsilvashy / Brewfile
Last active November 16, 2020 18:45 — forked from ryanhanwu/Brewfile
New Mac Setup Script 2019
# Taps
tap 'caskroom/cask'
tap 'homebrew/cask-fonts'
tap 'homebrew/cask-versions'
tap 'homebrew/bundle'
## Shell Utilities
brew 'coreutils'
brew 'zsh'
brew 'zsh-completions'
@jpsilvashy
jpsilvashy / generateAppIcon.sh
Last active December 29, 2018 15:34 — forked from roblabs/generateAppIcon.sh
Generate app icons and xcassets file from a single image. generateAppIcon.sh AppIcon.png
#!/bin/bash -e
# --------------------------------------------------------
# Generate app icons and xcassets file from a single image
# Ben Clayton, Calvium Ltd.
# https://gist.github.com/benvium/2be6d673aa9ac284bb8a
# --------------------------------------------------------
#
# Usage with an input of 1024x1024 PNG file
# generateAppIcon.sh AppIcon.png
@jpsilvashy
jpsilvashy / nodejs-webm
Created November 22, 2017 23:04 — forked from jbouny/nodejs-webm
Node.js WebM generation with whammy and sharp
var Whammy = require('node-whammy'),
sharp = require('sharp');
function canvasToWebp(canvas, callback) {
sharp(canvas.toBuffer()).toFormat(sharp.format.webp).toBuffer(function(e, webpbuffer) {
var webpDataURL = 'data:image/webp;base64,' + webpbuffer.toString('base64');
callback(webpDataURL);
});
# Towers of Hanoi
#
# Write a Towers of Hanoi game:
# http://en.wikipedia.org/wiki/Towers_of_hanoi
#
# In a class `TowersOfHanoi`, keep a `towers` instance variable that is an array
# of three arrays. Each subarray should represent a tower. Each tower should
# store integers representing the size of its discs. Expose this instance
# variable with an `attr_reader`.
#
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@jpsilvashy
jpsilvashy / README.md
Created November 21, 2013 18:45 — forked from vickash/README.md

Install rabbitmq first: http://www.rabbitmq.com/download.html Or brew install rabbitmq on Mac

Start it up with rabbitmq-server

Install gems to talk to the message queue:

gem install bunny
gem install amqp
#!/usr/bin/env python
from flask import Flask, jsonify, request, render_template, abort
from text.blob import TextBlob
from text.utils import strip_punc
app = Flask(__name__)
##### TextBlob API #####
@app.route("/api/sentiment", methods=['POST'])
def sentiment():
function hostReachable() {
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
// Open new request as a HEAD to the root hostname with a random param to bust the cache
xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false );
// Issue request and handle response
# add this to your config.rb
ready do
wikitargets = Hash.new
wikiwords = Hash.new
sitemap.resources.select {|p| p.ext == ".html" }.each do |p|
unless p.data['wikitag'].nil?
wikitargets[p.data['wikitag']] = p.url
end
@jpsilvashy
jpsilvashy / chat.rb
Created April 12, 2013 18:44 — forked from rkh/chat.rb
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do