Skip to content

Instantly share code, notes, and snippets.

@bgrins
bgrins / Log-.md
Last active August 1, 2023 16:32
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@manuelvanrijn
manuelvanrijn / chrome-sass-source-maps.md
Created April 4, 2013 06:29
Enable SASS support for your Rails project within chrome using source maps
  1. Goto chrome://flags and enable Enable Developer Tools experiments
  2. Open de Developer toolbar and goto the General tab within settings. Check the Enable source maps
  3. Restart chrome
  4. Open de Developer toolbar and goto the Expirements tab. Check "Support for Sass"

Add the following to your config/environments/development.rb

config.assets.debug = true
config.sass.debug_info = true
# each_with_objectの使い方
# ----------------------------------------
# 1. 簡単な使い方
each_with_objectは、引数のメモ化用オブジェクトを渡して、最後に必ず返す。
alpha_1 = []
('a'..'z').each do |str|
alpha_1 << str.upcase
@aoi0308
aoi0308 / fact.js
Last active December 20, 2015 17:58
JavaScriptでYコンビネータ。 fact.jsはそれを使って定義した関数。
function fact(n) {
return Y(fact0)(n);
}
document.write(fact(6));
@uupaa
uupaa / canvas.toDataURL.image.webp.md
Last active April 11, 2021 13:37
canvas.toDataURL("image/webp");
<canvas id="canvas"></canvas>
<script>
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 8, 8);

var webp = canvas.toDataURL("image/webp"); // Chrome only?
var png  = canvas.toDataURL("image/png");
var jpg = canvas.toDataURL("image/jpeg");
@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
@rosylilly
rosylilly / 00-actor.rb
Last active March 3, 2017 07:03
分かった気になる DCI 、ロミオとジュリエット編 Romeo & Juliette with DCI
# 役者クラス
#
# say: 役者は声を発する事ができる。
class Actor
def say(words)
puts words
end
end

GolangでWebAppを作るとき

GolangでWebアプリを作るときのまとめ。三回に分けて実施します。 初回と二回目はpureなgolangのコアモジュールを使って書いてみます。 初回はhttpモジュールについて二回目はDBを使った適当なWebAppを作ります。 三回目はrevelというgolangでは有名なWAFを使って書いてみます。

http.ListenAndServe

@KieranP
KieranP / 1 app-models-session.rb
Last active October 8, 2020 16:11
A Ruby on Rails implementation of a Database and Cookie hybrid session storage for Devise that supports session revocation and storage of session ip and user agent for security (similar to Github)
# A user session class, a simplified mix of the following code samples:
# * https://github.com/blog/1661-modeling-your-app-s-user-session
# * http://www.jonathanleighton.com/articles/2013/revocable-sessions-with-devise/
class Session < ActiveRecord::Base
# Uncomment if you use Hobo Fields, else add these yourself
# fields do
# session_id :string, :index => true, :unique => true
# accessed_at :datetime
# user_ip :string

いかにして我々はフロントエンドに秩序をもたらそうとしてきたか

@mizchi / Quipper

最初に

  • 人間性捧げすぎて資料作るの忘れてました