Skip to content

Instantly share code, notes, and snippets.

View jpsilvashy's full-sized avatar
🎯
Focusing

JP Silvashy jpsilvashy

🎯
Focusing
View GitHub Profile
deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free
deb http://deb.debian.org/debian stretch-updates main contrib non-free
deb-src http://deb.debian.org/debian stretch-updates main contrib non-free
deb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free
@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);
});
@jpsilvashy
jpsilvashy / README.md
Last active May 1, 2017 01:16
action schedule
@jpsilvashy
jpsilvashy / mq.js
Created March 4, 2017 04:19
A Simple RabbitMQ Client
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
var pubChannel = null;
var offlinePubQueue = [];
var mq = {
// Main start
@jpsilvashy
jpsilvashy / crime.py
Created August 3, 2016 14:20
CRIME demo
# This is supposedly what CRIME by Juliano Rizzo and Thai Duong will do
# Algorithm by Thomas Pornin, coding by xorninja, improved by @kkotowicz
# http://security.blogoverflow.com/2012/09/how-can-you-protect-yourself-from-crime-beasts-successor/
import string
import zlib
import sys
import random
charset = string.letters + string.digits + "%/+="
@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():
@jpsilvashy
jpsilvashy / test.rb
Last active December 20, 2015 03:59
def thing
if !this && that == true
if theother.count > 44 && yo.present?
# do this thing!!
end
end
end
def thing_2
if (!this && that == true) and (theother.count > 44 && yo.present?)
@jpsilvashy
jpsilvashy / grade.rb
Created July 18, 2013 00:35
Ruby Numeric class method for returning a letter grade as a string, takes any Numeric object, returns a string.
class Numeric
def to_grade
case self
when 97..100; grade = 'A+'
when 94..96; grade = 'A'
when 90..93; grade = 'A-'
when 87..89; grade = 'B+'
when 84..86; grade = 'B'
when 80..83; grade = 'B-'
when 77..79; grade = 'C+'
# 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