Skip to content

Instantly share code, notes, and snippets.

@averyvery
averyvery / seeds.rb
Created April 11, 2012 19:27
Seeding images in Rails
# encoding: utf-8
environment_seed_file = File.join(Rails.root, 'db', 'seeds', "#{Rails.env}.rb")
def seed_image(file_name)
File.open(File.join(Rails.root, "/app/assets/images/seed/#{file_name}.jpg"))
end
products = [
{:name => 'foo', :description => 'lorem ipsum', :product_type => ProductType.find_by_name('Sandwiches')},
@ronkorving
ronkorving / ios6-timers.js
Last active March 9, 2022 03:40
iOS6 webkit timer bug workaround
(function (window) {
// This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6.
// iOS6 suffers from a bug that kills timers that are created while a page is scrolling.
// This library fixes that problem by recreating timers after scrolling finishes (with interval correction).
// This code is released in the public domain. Do with it what you want, without limitations. I do not promise
// that it works, or that I will provide support (don't sue me).
// Author: rkorving@wizcorp.jp
var timeouts = {};
@ahomu
ahomu / totsuzen.js
Created January 30, 2013 11:12
% totsuzen 突然の死 | pbcopy
#!/bin/node
// via http://starwing.net/suddenly_death.html
String.prototype.lengthByte = function()
{
var str = this;
var r = 0;
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
@paulirish
paulirish / gist:5558557
Last active April 18, 2024 14:32
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@ympbyc
ympbyc / FunctionalJs.md
Last active April 26, 2023 12:26
Functional JavaScript

Functional JavaScript

2013 Minori Yamashita ympby@gmail.com

-- ここにあなたの名前を追記 --

目次

@ujihisa
ujihisa / vac230.md
Last active January 9, 2018 02:55
Vim Advent Calendar 2012 http://atnd.org/events/33746

Vim Advent Calendar 2012 ujihisa 15 (230日目)

Vim Advent Calendar 2012 の230日目の記事です。昨日の記事は@manga_osyoさんで、明日の記事はvital.vimコミッタの@rbtnnさんです。

今回は意表をついてVim scriptの入門記事です。

Vim script入門!

Vim script初級者レベルを10段階に分割すると、そのうち簡単な方から3つは、以下のようになります。

redcaretとgithub-markdownの違い

  • 両者のソースは割りと似ている(github-markdownがredcarpetを元にしたのか、あるいは両者のもとになったC実装があるとかかな)

オプションについて

github-markdownは、redcapetの提供するオプションの一部をデフォルトで有効化します。 (ちなみに有効化するオプションを選ぶAPIはない模様。用途を考えるとそれで正しいが)

★がついているのが有効化されるもの。gfmモード(.render_gfmメソッド)の場合のみ、★★も有効化される。

@1000ch
1000ch / app.js
Last active December 3, 2019 02:07
WebRTC video chat with PeerJS.
(function(global) {
// Compatibility
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
var peerClient;
var currentPeerConnection;
var localMediaStream;
$(function() {

By Saad Mousliki

御存知の通り、JavaScriptは数あるプログラミング言語のうちのひとつであり、モバイルのハイブリッドアプリ(PhoneGapやAppceleratorといった)や、サーバーサイド(NodeJSやWakanda)等の様々な所で実装されているWebの言語です。 また、Webブラウザにalertを出すところから、ロボットを動かす(nodebotやnodruinoを使って)ところまで様々なシーンで使われる言語となりました。 JavaScriptをマスターし、パフォーマンスの良いコードを生み出す開発者は市場で最も求められています。

@btd
btd / es6-arrows.sjs
Last active January 4, 2016 18:59
One attempt to make arrow functions from es6
macro => {
rule infix { ( $arg:ident (,) ... ) | { $body ... $last:expr } } => {
(function x( $arg (,) ... ) {
$( $body) ...
return $last
}).bind(this);
}
rule infix { ( $arg:ident (,) ... ) | $last:expr } => {
(function x( $arg (,) ... ) {
return $last