Skip to content

Instantly share code, notes, and snippets.

@haggen
haggen / less.js
Created Mar 5, 2021
Next.js v9/v10 integration for LESS leveraging built-in support for SASS
View less.js
const cloneDeep = require("clone-deep");
const { readFileSync, existsSync } = require("fs");
const path = require("path");
// next-less (official plugin to integrate Less) is now
// deprecated so we have to provide our own solution.
//
// Next.js already provides built-in integration with CSS and Sass, but it
// relies on a dynamic WebPack config. generation to do it optimally.
//
View *babel-plugin-transform-mui-imports.md

babel-plugin-transform-mui-imports npm

A plugin to make authoring with MUI components efficient, both for humans and bundlers.

Here's why:

View RecordPerfButton.coffee
React = require 'react'
Perf = require 'react-addons-perf'
ReactDOM = require 'react-dom'
rd = React.DOM
###
Usage: `require('debug/RecordPerfButton').attachToDOM()`
Add to any file to attach a record button to the DOM, toggleable via click and <alt> keypress.
Useful for quickly testing performance as it will:
@longtimeago
longtimeago / squash-commits.md
Last active Jun 13, 2022
How to squash commits in a GitHub pull request
View squash-commits.md

How to squash commits in a GitHub pull request

o you've contributed some code to an open source project, say, Rails. And they'd like you to squash all of the commits in your pull request. But you're not a git wizard; how do you make this happen?

Normally, you'd do something like this. I'm assuming upstream is a git remote that is pointing at the official project repository, and that your changes are in your 'omgpull' branch:

@ldong
ldong / download_egghead_videos.md
Last active Dec 18, 2021
download egghead videos
View download_egghead_videos.md

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@xmlking
xmlking / Enum.es6.js
Last active Jun 25, 2019
JavaScript Enums with ES6, Type Checking and Immutability
View Enum.es6.js
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@jalberto
jalberto / remote_cache_with_project_root_strategy.rb
Created May 6, 2014
Capistrano 3.1.x Strategy to deploy git projects with subdirectories
View remote_cache_with_project_root_strategy.rb
# Usage:
# 1. Drop this file into lib/capistrano/remote_cache_with_project_root_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/remote_cache_with_project_root_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, RemoteCacheWithProjectRootStrategy
# set :project_root, 'subdir/path'
# Define a new SCM strategy, so we can deploy only a subdirectory of our repo.
@sgress454
sgress454 / iterm_smart_select_for_node_stack_traces.txt
Created Mar 4, 2014
iTerm smart select to open Node stack traces in Sublime
View iterm_smart_select_for_node_stack_traces.txt
To set up iTerm 2 so you can open files referenced in a Node stack trace directly in Sublime:
1. Go to Preferences->Advanced
2. Under "Smart Selection", click the "EDIT" button
3. Click the + to add a new rule
4. For the Regular expression, user ^\s*at.*\((.+)\)
5. For priority, choose Very High
6. Click "Edit Actions"
7. Click the + to add a new action
8. Title "Open in Sublime"
@emiller
emiller / git-mv-with-history
Last active Aug 4, 2022
git utility to move/rename file or folder and retain history with it.
View git-mv-with-history
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@reversepanda
reversepanda / gist:5814547
Created Jun 19, 2013
CoffeeScript: getter/setter example
View gist:5814547
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'