Skip to content

Instantly share code, notes, and snippets.

Avatar

Han apricot13

View GitHub Profile
@ChristopherA
ChristopherA / README.md
Last active May 26, 2022 — forked from idelem/titleUrlMarkdownClip.js
Copy current page title and url in Markdown format
View README.md

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

@MarcoWorms
MarcoWorms / mini-redux.js
Last active Sep 24, 2021
Redux in a nutshell
View mini-redux.js
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
View getClassNames.js
function *traverse(item) {
for ( var child of item.children ) {
if (child.className) {
yield* child.classList;
}
if (child.childElementCount !== 0) {
yield* traverse(child);
}
}
}
@webdevilopers
webdevilopers / ContractController.php
Last active Mar 11, 2020
Symfony Event Listener to send html mail using SwiftMailer and Twig
View ContractController.php
<?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 Jan 8, 2015
Git: Feature branch workflow
View git_feature_branch
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
@willurd
willurd / Getting started with requirejs.md
Last active Jun 11, 2022
A short introduction to require.js
View Getting started with requirejs.md

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.

@ryoppy
ryoppy / getQueryParams.js
Last active Mar 28, 2019
Parse query string. use Underscore.js.
View getQueryParams.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;
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active Jun 19, 2022
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.
View node-and-npm-in-30-seconds.sh
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