Skip to content

Instantly share code, notes, and snippets.

Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
Transis && (Transis.Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
});
@congwenma
congwenma / Jasmine-and-Babel6.md
Created July 22, 2016 15:40 — forked from mauvm/Jasmine-and-Babel6.md
Jasmine ES6 run script for use with Babel 6
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine

.babelrc:

{
 "presets": ["es2015"]
@congwenma
congwenma / hotkeys.js
Last active September 1, 2016 07:45
setting hotkeys in the browser to trigger callbacks defined
// Provides an api for browser windows to set hotkey combinations to functions.
// e.g.:
// hotkeys.register(['e', 'q', 'alt'], function() {
// console.log('e, q, and alt have been pressed simultaneously')
// }, {
// continuous: false // will not unregister trigger
// })
//
// these are only available via keyup
@congwenma
congwenma / osx-dark-mode-everything.md
Created March 10, 2017 17:25 — forked from mswieboda/osx-dark-mode-everything.md
OS X Dark Mode Everything 🕶️ 🏴

OS X Dark Mode Everything 🕶️ 🏴

OS X Dark Menu Bar and Dock

System Preferences > General > Use dark menu bar and Dock

See if your menu bar icons can be switched to black, so they appear white for dark menu bar, most apps have an option in settings.

Chrome Extensions

@congwenma
congwenma / touch_corrupting_lcok_version.rb
Last active April 6, 2017 19:48
Single file rails application
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@congwenma
congwenma / fakestring.js
Last active June 15, 2017 17:31
generate string of length
const fakeString = n => Array.from(Array(n || 10).keys()).map(n => String.fromCharCode(Math.floor(Math.random()*26) + 97)).join('')
@congwenma
congwenma / Dark theme - Github for desktop.js
Last active April 2, 2018 21:29
working slack dark theme
var html_file = require("path").join(process.resourcesPath, "app/index.html");
var html = require("fs").readFileSync(html_file, "utf8");
var link_to_inject = '<link href="https://cdn.rawgit.com/ObserverOfTime/07e862ec7240d995e672818f43513bc7/raw/06c86e69c94935962b07b5302c195f7d6465eacd/desktop-dark.css" rel="stylesheet">';
html = html.replace(link_to_inject, "").replace("</head>", `\n${link_to_inject}</head>`);
require("fs").writeFileSync(html_file, html, "utf8");
location.reload();
@congwenma
congwenma / react16_event_handler_undefined_or_function.js
Last active February 9, 2022 11:58
codemod: react 16 event prop warning if passes in boolean
/* eslint-disable */
const EVENT_NAMES = ['onMouseDown', 'onMouseUp', 'onClick', 'onKeyUp', 'onKeyDown']
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
let foundAttrs = j(file.source).find(j.JSXAttribute)
var replacements = []
foundAttrs = foundAttrs.forEach(path => {
@congwenma
congwenma / learn-docker.md
Created September 13, 2018 20:09
learn docker notes

docker container run --publish 80:80 nginx

  1. Downloaded latest image nginx from Docker Hub
  2. Started a new container from that image
  3. Opened port 80 on the host IP (1st 80)
  4. Routes that traffic to the container IP, port 80 (2nd 80)
@congwenma
congwenma / gist:634ab96da2d880237f83211d0545dffe
Created March 2, 2024 23:40 — forked from shiritrong/gist:d85bb1e16c66d1a09896727780b4fc7c
Windows 7 All Online/Offline [Retail-MAK] Activation Keys
Windows 7 All Online/Offline [Retail-MAK] Activation Keys
=================================================================================
. Run "Command Prompt" as Administrator
. slmgr.vbs -ipk Product Key
. slui4
=================================================================================
Windows 7 Ultimate Retail Phone Activation Keys
RHTBY-VWY6D-QJRJ9-JGQ3X-Q2289
V77DJ-CT8WB-Y3GXT-X3FBP-6F987
JC7BV-94FD2-D86PH-XRMHR-BXKDG