Skip to content

Instantly share code, notes, and snippets.

@sunvisor
sunvisor / jsdoc.vim
Created October 17, 2012 04:54
insert jsdoc style comment. (vim function)
" JSDoc形式のコメントを追加(functionの行で実行する)
" hogeFunc: function() の形式と function hogeFunc() に対応
" 関数定義でない場合は、コメントだけ出力する
function! AddJSDoc()
let l:jsDocregex = '\s*\([a-zA-Z]*\)\s*[:=]\s*function\s*(\s*\(.*\)\s*).*'
let l:jsDocregex2 = '\s*function \([a-zA-Z]*\)\s*(\s*\(.*\)\s*).*'
let l:line = getline('.')
let l:indent = indent('.')
let l:space = repeat(" ", l:indent)
@josephj
josephj / mask.scss
Created October 19, 2012 02:50
A pure CSS mask which centralizes content inside. ( http://josephj.com/lab/2012/mask/demo.html )
@import "compass";
/**
* A pure CSS mask which centralizes content inside.
* This technique is compatible with IE7+ and major standard browsers.
*
* Required HTML structure:
*
* <div class="mask">
* <div class="mask-box">
* <div class="mask-inner-box">
@impressiver
impressiver / raven-config.html
Last active February 27, 2024 14:27
Raven.js configuration for logging JavaScript exceptions to Sentry (https://getsentry.com/). Without the added ignore options, you'll quickly find yourself swamped with unactionable exceptions due to shoddy browser plugins and 3rd party script errors.
<!-- Raven.js Config -->
<script src="{{ JS_PATH }}/lib/raven.js" type="text/javascript"></script>
<script type="text/javascript">
// Ignore list based off: https://gist.github.com/1878283
var ravenOptions = {
// Will cause a deprecation warning, but the demise of `ignoreErrors` is still under discussion.
// See: https://github.com/getsentry/raven-js/issues/73
ignoreErrors: [
// Random plugins/extensions
'top.GLOBALS',
@dannvix
dannvix / Sorting-Color-Nodes-by-Hue.html
Last active December 19, 2015 22:49
Simple visualization for sorting color nodes by hue
<!DOCTYPE html>
<html>
<head>
<title>Sorting Color Nodes by Hue</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
overflow: hidden;
background: #333333;
}
@andrewgleave
andrewgleave / AnimatableComponent.js
Last active May 17, 2024 02:06
Keyframe animation support for React. Enables integration between React components and JS animation events.
/** @jsx React.DOM */
'use strict';
var React = require('react');
var AnimatableComponent = React.createClass({
propTypes: {
tag: React.PropTypes.component.isRequired,
@kejun
kejun / gist:3f4851c7f3b3e209fcbb
Last active July 9, 2019 15:23
最近一次项目的总结

mathclub是最近做的一个个人项目,帮助考SAT的同学通过在线做题、回顾、问答提高成绩。用户功能有:计次/计时做题、成绩单、错题分布、错题回顾、提问、汇总以及注册登录。管理后台主要是题库管理、学员管理、成绩单管理、问题回复。怎么看都像学校里的课设,的确项目本身并不出奇,开发上选用的一些方案或许更有意思。

整个项目一个人从产品需求、原型设计、前后端开发到部署历时2周左右。可以从截图上感受一下:

image

技术选型上服务端是Node.js,应用框架选了老牌的Express(4.x变化挺大不少中间件都废了),数据服务用的是MongoLab(MongoDB的云服务平台),图片上传用的是又拍云,程序部署在Nodejitsu上。模板引擎没选主流的Jade或ejs,而是用Express React Views它实现了在服务端渲染React组件。前端框架是用React,这次有意想追求前后端全部组件化的组织。之前是用Webpack实现CommonJS模块打包,这次用Browserify配置更简单,它有丰富的transform很赞,其中的reactify转换React的JSX很完美。CSS用Sass+autoprefixer让人省心。将这一切串起来的自动构建工具是Gulp。我其实崇尚用最精简的工具组合开发,上述组合在我看来比较精简了。(帖纸留念)

![image](http://satexam.b0.upaiyu

@josephj
josephj / gulpfile.coffee
Last active August 29, 2015 14:08
Development tools for developer portal project
################
# Dependencies
################
gulp = require 'gulp'
watch = require 'gulp-watch'
connect = require 'gulp-connect'
open = require 'gulp-open'
path = require 'path'
exec = require('child_process').exec
################
@timkelty
timkelty / selects.js
Created February 19, 2015 16:39
Custom select2 adapter
// jshint maxparams: 8
define([
'jquery',
'fmjs/amd/src/fm.timer',
'Select2/src/js/select2/utils',
'Select2/src/js/select2/dropdown',
'Select2/src/js/select2/dropdown/attachContainer',
'Select2/src/js/select2/dropdown/search',
'Select2/src/js/select2/dropdown/minimumResultsForSearch',
'Select2/src/js/jquery.select2',
@josephj
josephj / .gitconfig
Last active August 29, 2015 14:20
Basic .gitconfig file
[alias]
st = status
br = branch
ci = commit
cp = cherry-pick
co = checkout
sub = submodule
[diff]
color = auto
@Yimiprod
Yimiprod / difference.js
Last active May 10, 2024 16:49
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {