Skip to content

Instantly share code, notes, and snippets.

@mohayonao
mohayonao / overloadable.coffee
Last active December 17, 2015 22:29
CoffeeScriptで演算子のオーバーロードっぽいやつ
overloadable = do ->
operator = (op, b)->
a = @value()
b = b.value?() ? b
fn = switch op
when '+' then (a, b)-> a + b
when '-' then (a, b)-> a - b
when '*' then (a, b)-> a * b
when '/' then (a, b)-> a / b
if Array.isArray(a)
@pixelhandler
pixelhandler / pre-push.sh
Last active July 2, 2024 11:27
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@zakgrant
zakgrant / multi-type-schema.json
Created July 1, 2013 11:15
This is how to represent an object that can have multiple types within a JSON Schema
{
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [
{
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
{
"type": "string",
language: node_js
node_js:
- "0.10"
before_install:
- npm install -g grunt-cli bower
- npm install
- grunt
- npm test
@soplana
soplana / gist:6070449
Created July 24, 2013 13:10
なんだこの挙動

localを参照するeval

var name = "soplana";
var user = {
	getName : function(){
	  var name = "javascript";
	  return (eval)("name");
	}
}
@BlackPrincess
BlackPrincess / javascriptのカンマ構文.md
Created July 24, 2013 15:44
javascriptにもカンマ構文があったらしい・・・

抜き打ちテストが分からなかった

じゃあ this の抜き打ちテストやるぞーをやってみた。
結果として、コードが読めなくて2問空欄解答をするしかなかったので調べてみました。

あ、やってない人は読む前に先にやってみてください。
ちなみにthisの話はあんまりしません。
そして今日調べたばかりなので間違っている可能性や、そもそも自分の知識不足のせいでバカ発見されただけかも知れません。

ただのindirect eval

花火~ 最高な俺たちと糞コードの海

written by mizchi at 小物エンジニアの会.

最高の夏の花火について 花火

自己紹介

@voluntas
voluntas / shiguredo_tech.rst
Last active May 13, 2025 02:58
時雨堂を支える技術

時雨堂を支える技術

日時:2025-05-13
作:時雨堂
バージョン:2025.3
URL:https://shiguredo.jp/

言語

@hail2u
hail2u / Gruntfile.js
Last active June 27, 2025 19:42
This Grunt task renders `foo.hbs` using data based on `metadata.json` (Base) and `foo.json` (Extend) with Handlebars.js. `foo.hbs` can include other Handlebars.js template (e.g. `styles.inc.hbs`).
module.exports = function (grunt) {
grunt.initConfig({
generate: {
all: {
expand: true,
cwd: '.grunt/html/',
src: ['**/*.hbs', '!**/*.inc.hbs'],
filter: 'isFile',
dest: './',
ext: '.html'