Skip to content

Instantly share code, notes, and snippets.

View beatak's full-sized avatar
🍄
Mushroom

Takashi M beatak

🍄
Mushroom
  • San Francisco, CA
View GitHub Profile
class CrudeTimingPlugin {
apply(compiler) {
compiler.plugin('compilation', compilation => {
let startOptimizePhase;
compilation.plugin('optimize-chunk-assets', (_chunks, callback) => {
// Cruddy way of measuring minification time. UglifyJSPlugin does all
// its work in this phase of compilation so we time the duration of
// the entire phase
startOptimizePhase = Date.now();
console.log('starting the web server!');
const http = require('http');
const _env = parseInt(process.env.PORT, 10);
const PORT = _env ? _env : 80;
http.createServer(function (req, res) {
console.log(`Req: ${req.url}`);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world');
import json
from datetime import date, datetime, timedelta
def json_serial(obj):
if isinstance(obj, (datetime, date)):
return obj.isoformat()
elif isinstance(obj, (timedelta)):
return obj.total_seconds()
raise TypeError ("Type %s not serializable" % type(obj))
const findCombination = function (totalMoney, priceA, priceB, totalHeads) {
const result = [];
let countA, countB;
for (let i = 0; i < totalHeads; ++i) {
countA = i;
countB = totalHeads - i;
if (totalMoney === (countA * priceA + countB * priceB)) {
result.push([countA, countB]);
}
}
@beatak
beatak / one-liner.sh
Created April 10, 2018 18:30
Removing escape sequence like a l33t
perl -ne 's/\x1b[[()=][;?0-9]*[0-9A-Za-z]?//g;s/\r//g;s/\007//g;print' < foo.log
diff --git a/Gemfile b/Gemfile
index c9eea6e44f..4530c4a45e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -112,7 +112,7 @@ gem "slack-notifier" # used to send notifications when a sitemap is being genera
# :staging rake task uses this, and this would run in
# production environment
-gem 'pgsync'
+gem 'pgsync', :git => 'https://github.com/ankane/pgsync.git', :branch => 'master'
yarn run v1.3.2
$ NODE_ENV=test-jest jest --coverage
RUNS ...RealtorSpec.jsx
RUNS ...CallModalSpec.jsx
RUNS ...ContactModalSpec.jsx
RUNS ...NotificationCardSpec.jsx
RUNS ...NotificationsSpec.jsx
RUNS ...duckSpec.jsx
RUNS ...ListingCardSpec.jsx
#!/bin/sh
ssh -C -Y ${USER}@${HOSTNAME}
#!/bin/sh
target_shell=$1
if [ -z "$1" ]; then
target_shell=$(basename "$SHELL")
fi
if [ "$target_shell" = "bash" ]; then
bash <<< 'for code in {0..255}; do echo -n "[38;05;${code}m $(printf %03d $code)"; [ $((${code} % 16)) -eq 15 ] && echo; done'

Keybase proof

I hereby claim:

  • I am beatak on github.
  • I am beatak (https://keybase.io/beatak) on keybase.
  • I have a public key ASCMxDiWtOsilxFQFd_5ebV6pKD3c8vvW_bR5e-IsRyF-Qo

To claim this, I am signing this object: