Skip to content

Instantly share code, notes, and snippets.

View apricot13's full-sized avatar

Han apricot13

View GitHub Profile
@stephenwf
stephenwf / getClassNames.js
Created August 25, 2016 10:52
Class Name list
function *traverse(item) {
for ( var child of item.children ) {
if (child.className) {
yield* child.classList;
}
if (child.childElementCount !== 0) {
yield* traverse(child);
}
}
}
@ryoppy
ryoppy / getQueryParams.js
Last active March 28, 2019 17:31
Parse query string. use Underscore.js.
/**
* Parse query string.
* ?a=b&c=d to {a: b, c: d}
* @param {String} (option) queryString
* @return {Object} query params
*/
getQueryParams: function(queryString) {
var query = (queryString || window.location.search).substring(1); // delete ?
if (!query) {
return false;
@webdevilopers
webdevilopers / ContractController.php
Last active March 11, 2020 09:00
Symfony Event Listener to send html mail using SwiftMailer and Twig
<?php
namespace Acme\Bundle\ContractBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ContractController extends Controller
{
public function eventAction(Contract $contract)
{
$event = new ContractEvent($contract);
@apricot13
apricot13 / git_feature_branch
Created January 8, 2015 12:33
Git: Feature branch workflow
git checkout -b feature-branch master
git status
git add <some-file>
git commit
git push -u origin feature-branch
git push
git checkout master
@ChristopherA
ChristopherA / README.md
Last active May 26, 2022 11:03 — forked from idelem/titleUrlMarkdownClip.js
Copy current page title and url in Markdown format

Copy current page title and url in Markdown format

Tags: #bookmarklet #curation #markdown

Bookmarklet to copy current page title and url in Markdown format to clipboard, like title - Usual for posting links to resources in README.md files #bookmarklet #safari #markdown #tool

Originally from: https://gist.github.com/jbrown123/84839a5abe763e5b117a321510cb9de7

@willurd
willurd / Getting started with requirejs.md
Last active December 14, 2022 08:15
A short introduction to require.js

This is a small collection of scripts showing how to use require.js. It's only one of several ways of setting up a require.js project, but it's enough to get started.

At its core, require.js is about three things:

  1. Dependency management
  2. Modularity
  3. Dynamic script loading

The following files show how these are achieved.

@MarcoWorms
MarcoWorms / mini-redux.js
Last active August 7, 2023 19:06
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh