Skip to content

Instantly share code, notes, and snippets.

@mynnx
mynnx / componentCompositions.template
Last active August 5, 2022 17:16
Turning Figma Tokens composition tokens into SCSS!
<%= fileHeader({file, commentStyle: 'long'}) %>
<% variableTokens.forEach(({name, value}) => { %>
$<%= name %>-color: <%= value %>;<% }); %>
<% Object.entries(compositionCssRules).forEach(([name, rules]) => { %>
%<%= name %> {<% rules.forEach(({rule, value}) => { %>
<%= rule %>: <%= value %>;<% }) %>
}
<% }) %

JavaScript

Creating vanilla objects
  • Object.create(null) is one way
  • Using Maps lets you store properties that might collide with JS built-ins:
  • new Map([['name', 'Jean-Luc Picard']])

Spreading tricks

Keybase proof

I hereby claim:

  • I am mynnx on github.
  • I am mynnx (https://keybase.io/mynnx) on keybase.
  • I have a public key whose fingerprint is 47A6 130B 68A1 4381 8764 2665 D6DD 69F0 C282 F200

To claim this, I am signing this object:

@mynnx
mynnx / npm install yarn -g fails.sh
Last active December 28, 2016 20:39
Yarn install failure
$ ./scripts/ci/build
npm WARN deprecated yarn@0.18.1: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
/opt/local/nvm/versions/node/v6.9.1/bin/yarn -> /opt/local/nvm/versions/node/v6.9.1/lib/node_modules/yarn/bin/yarn.js
/opt/local/nvm/versions/node/v6.9.1/bin/yarnpkg -> /opt/local/nvm/versions/node/v6.9.1/lib/node_modules/yarn/bin/yarn.js
> spawn-sync@1.0.15 postinstall /opt/local/nvm/versions/node/v6.9.1/lib/node_modules/yarn/node_modules/spawn-sync
> node postinstall
/opt/local/nvm/versions/node/v6.9.1/lib
└─┬ yarn@0.18.1
@mynnx
mynnx / vacuum_server.py
Created March 27, 2014 22:26
Email-controlled Vacuum Server
import flask
from time import sleep
import redis
from flask import Flask, request
r = redis.StrictRedis(host='localhost', port=6379, db=0)
app = Flask(__name__)
class Robot(object):
(master) $ node get-sms.js
{ code: 100,
message: 'UNKNOWN_FORMAT',
details:
{ res:
{ _readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_maxListeners: 10,
vagrant@reach:~$ sudo apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
@mynnx
mynnx / whargarbl.py
Created January 16, 2012 11:33
provider_comm error, jan 16 2012
Jumping into debugger for post-mortem of exception ''NoneType' object has no attribute 'hash_key'':
> /data/ck/cloudkick/webapp/inventory/models.py(1105)provider_with_creds()
-> return self.get_query_set().filter(api_key_uniq=pcreds.hash_key,
(Pdb) bt
/usr/lib/python2.6/dist-packages/twisted/python/threadpool.py(210)_worker()
-> result = context.call(ctx, function, *args, **kwargs)
/usr/lib/python2.6/dist-packages/twisted/python/context.py(59)callWithContext()
-> return self.currentContext().callWithContext(ctx, func, *args, **kw)
/usr/lib/python2.6/dist-packages/twisted/python/context.py(37)callWithContext()
-> return func(*args,**kw)
@mynnx
mynnx / rackspace_lb_lc.py
Created December 21, 2011 21:32
rackspace LB API - timing async actions
test_lb = [b for b in balancers if b.name == 'Mark - T1'][0]
updated_balancer = conn.update_balancer(test_lb,
name='Mark - T2',
protocol='HTTPS',
port=84,
algorithm=Algorithm.ROUND_ROBIN)
import time
start = time.time()
while updated_balancer.state != State.RUNNING:
@mynnx
mynnx / ohgodwhyWHYWHY???.py
Created November 2, 2011 18:06
iterate across classattrs
class Soda:
ITALIAN_BUBBLY_STUFF_IN_A_GLASS_BOTTLE = 'crap'
KROGER_BRAND_SODA = 'also crap'
class Pepsi:
MOUNTAIN_DEW = 'awesome'