Skip to content

Instantly share code, notes, and snippets.

@minipai
minipai / queryString.js
Created September 11, 2020 13:10
query-string native replacement
const SearchParams = {
parse(queryString) {
return Object.fromEntries(new URLSearchParams(queryString).entries())
},
stringify(query) {
return new URLSearchParams(query).toString()
}
}
@minipai
minipai / jsconfig.json
Last active January 9, 2019 11:26
jsconfig.json for Stackla web
{
"compilerOptions": {
"target": "es2018",
"jsx": "react",
"baseUrl": "./app/media/",
"paths": {
"admin/*": [
"js/admin/*"
],
"common/*": [
@minipai
minipai / json
Created February 15, 2018 20:17
jsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "ES6",
"baseUrl": "./",
"paths": {
"~/*": ["./*"]
}
},
"exclude": [
@minipai
minipai / plugin.js
Created October 24, 2016 23:38
babe plugin add Component name on div
module.exports = function (babel) {
var t = babel.types;
var visitor = {
ClassDeclaration: function(code) {
var node = code.node;
var className = node.id.name;
var renderMethod;
for (i=0; i<code.node.body.body.length; i++) {
var method = code.node.body.body[i];
@minipai
minipai / styleguide.jsx
Created March 4, 2015 10:10
Use ReactJS to create style guide
var React = require('react');
var beautify = require('js-beautify').html
var StyleBlock = React.createClass({
render: function () {
var Element = this.props.element
return (
@minipai
minipai / express-renderReact.js
Created February 13, 2015 02:36
Express middleware to render react.js on server side, with react-router
var React = require('react');
var Router = require('react-router');
var DocumentTitle = require('react-document-title');
var reactRoutes = require('../view/_route.jsx');
var Html = require('../view/Html.jsx');
/**
* @name RenderView
* @constructor
$iphone-query = "only screen and (max-width: 480px)"
$ipad-query = "only screen and (min-width: 481px) and (max-width: 768px)"
$screen-query = "only screen and (min-width: 768px) and (max-width: 1300px)"
$wide-screen-query = "only screen and (min-width: 1301px)"
$tablet-query = "only screen and (max-width: 1024px)"
$mobile-query = "only screen and (max-width: 767px)"
$desktop-query = "only screen and (min-width: 768px)"
var mongoose = require( 'mongoose' )
, ObjectId = mongoose.Schema.Types.ObjectId
, Board = mongoose.model( 'Board' )
, BoardAdmin = mongoose.model( 'BoardAdmin' )
, Post = mongoose.model( 'Post' )
exports.show = function(req, res) {
var data = {}
@minipai
minipai / post-checkout
Created March 3, 2014 09:24
Brach changed, do Gulp.
#! /bin/bash
# Exit early if this was only a file checkout, not a branch change ($3 == 1)
[[ $3 == 0 ]] && exit 0
echo "Brach changed, do Gulp."
cd "$GIT_DIR/../biideal/static"
pwd
gulp
@minipai
minipai / CoffeeScriptSong.md
Last active August 29, 2015 13:56
Song of CoffeeScript "Let It(Semicolon) Go"

Let It(Semicolon) Go

The snow glows white on the mountain tonight

Not a footprint to be seen

A kingdom of isolation,

And it looks like I’m nobody.