Skip to content

Instantly share code, notes, and snippets.

View dtaniwaki's full-sized avatar

Daisuke Taniwaki dtaniwaki

View GitHub Profile
@mnylen
mnylen / ScalatraFileUploadTests.scala
Created April 6, 2012 19:11
postMulti() helper for scalatra-test for making multipart/form-data requests. Useful when testing file uploads with scalatra-fileupload
import org.apache.commons.io.IOUtils
import org.eclipse.jetty.http.HttpHeaders
import org.eclipse.jetty.testing.HttpTester
import org.eclipse.jetty.io.ByteArrayBuffer
import util.DynamicVariable
import org.scalatra.test.ScalatraTests
import java.net.HttpCookie
import java.io.{ByteArrayOutputStream, FileInputStream, File}
trait ScalatraFileUploadTests extends ScalatraTests {
@bengfarrell
bengfarrell / randomcoords.cpp
Last active May 5, 2025 13:09
Random Coordinates C++ Node.JS AddOn
#include <node.h>
#include <v8.h>
#include <stdio.h>
#include <stdlib.h>
using namespace v8;
Handle<Value> getRandomCoords2D(const Arguments& args) {
HandleScope scope;
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 28, 2025 00:02
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@daxanya2
daxanya2 / fabric.js
Created December 28, 2013 12:19
็„กๆ–™ใฎใ‚ตใƒผใƒ“ใ‚นใ‚’ไฝฟใฃใฆHubotใงๅ‹•็š„ใซ็”ปๅƒใ‚’็”Ÿๆˆใ—ใฆ่ฟ”ใ™ ref: http://qiita.com/daxanya1/items/a352e894491bd396a97d
(function() {
var fabric, fs, mktemp, d3;
d3 = require('d3');
mktemp = require('mktemp');
fabric = require('fabric').fabric;
fs = require('fs');
path = require('path');
module.exports = function(robot) {
@sudara
sudara / puma.monitrc
Last active November 3, 2023 12:03
Example config needed to use monit with puma, monitoring workers for mem.
# this monit config goes in /etc/monit/conf.d
check process puma_master
with pidfile /data/myapp/current/tmp/puma.pid
start program = "/etc/monit/scripts/puma start"
stop program = "/etc/monit/scripts/puma stop"
group myapp
check process puma_worker_0
with pidfile /data/myapp/current/tmp/puma_worker_0.pid
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@rtt
rtt / tinder-api-documentation.md
Last active May 17, 2025 02:57
Tinder API Documentation

Tinder API documentation

Note: this was written in April/May 2014 and the API may has definitely changed since. I have nothing to do with Tinder, nor its API, and I do not offer any support for anything you may build on top of this. Proceed with caution

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

@roachhd
roachhd / README.md
Last active May 19, 2025 15:24
EMOJI cheatsheet ๐Ÿ˜›๐Ÿ˜ณ๐Ÿ˜—๐Ÿ˜“๐Ÿ™‰๐Ÿ˜ธ๐Ÿ™ˆ๐Ÿ™Š๐Ÿ˜ฝ๐Ÿ’€๐Ÿ’ข๐Ÿ’ฅโœจ๐Ÿ’๐Ÿ‘ซ๐Ÿ‘„๐Ÿ‘ƒ๐Ÿ‘€๐Ÿ‘›๐Ÿ‘›๐Ÿ—ผ๐Ÿ”ฎ๐Ÿ”ฎ๐ŸŽ„๐ŸŽ…๐Ÿ‘ป

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. โœˆ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: ๐Ÿ˜„

@beam2d
beam2d / invidx.py
Last active October 28, 2021 21:34
Inverted index in NumPy
import numpy as np
class InvertedIndex(object):
def __init__(self, x):
self.J = np.argsort(x)
D = np.ediff1d(x[self.J], to_begin=1, to_end=1)
self.I = np.repeat(np.arange(len(D)), D)
def __getitem__(self, k):
@msakai
msakai / autoencoder_vs_pca.ipynb
Created June 20, 2017 16:58
Autoencoder vs PCA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.