Skip to content

Instantly share code, notes, and snippets.

@shuhei
shuhei / convert-textile.js
Created January 25, 2020 23:04
Convert textile files into markdown files
const { promises: fs } = require("fs");
const textile = require("textile-js");
const prettier = require("prettier");
const path = require("path");
async function main() {
const postsDir = path.resolve("source", "_posts");
const files = (await fs.readdir(postsDir)).filter(file =>
file.endsWith(".textile")
);
@ersinakinci
ersinakinci / electron-webpack-node-integration-false.md
Last active January 25, 2023 19:03
Making electron-webpack work with nodeIntegration: false

NOTE, April 18, 2020: I wrote this document in February 2019 when I was actively investigating Electron. I haven't used it since then and have largely forgotten what this was for or how electron-webpack works. I vaguely remember the problem, but that's it. It would appear based on the comments below that this document is still coming up in web searches but has become out of date and parts of it don't work. If anyone has specific fixes to my instructions, please leave them in the comments and I'll happily incorporate them.

Using electron-webpack without Node integration

Overview

The current version (as of 2019-02-02) of electron-webpack is set up with the assumption that your BrowserWindow instance has nodeIntegration: true. However, Electron is encouraging users to set nodeIntegration: false as a security precaution, and in the future BrowserWindows will have this setting set to false by default. Doing so now with electron-webpack throws an error because the index.html template has commonjs re

@jimmed
jimmed / suitcx.js
Created August 8, 2016 10:27
It's `suitcx`. Like `cx`, but wearing a suit.
import cx from 'classnames'
import capitalize from './capitalize'
/**
* It's `suitcx`. Like `cx`, but for suitCSS
*
* @param {string} parent - The main suitCSS class, i.e. `ChatItem` or `ChatItem-message`.
* @param {Object} [modifiers] - The suitCSS modifiers to apply, where each key is the name of the modifier applied. For each key/value pair of the object; if a value is a string, the modifier name will be the value appended to the key (in camel-case); otherwise, the modifier will only be added if the value is truthy.
* @param {Object} [state] - The suitCSS state to apply, where each key is the name of the state to be applied, and the value used to determine whether to apply the state.
*
@Yimiprod
Yimiprod / difference.js
Last active April 5, 2024 13:17
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) {
@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
@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 / 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
################
@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

@andrewgleave
andrewgleave / AnimatableComponent.js
Last active November 27, 2018 20:41
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,
@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;
}