Skip to content

Instantly share code, notes, and snippets.

View ichim-david's full-sized avatar

David Ichim ichim-david

  • Romania
View GitHub Profile
@ichim-david
ichim-david / app.js
Last active August 29, 2015 14:16 — forked from ryanflorence/app.js
/** @jsx React.DOM */
var api = 'http://addressbook-api.herokuapp.com/contacts';
var App = React.createClass({
mixins: [Routed],
render: function() {
return (
<Root>
<Index path="/"/>
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- All rules for your theme diazo -->

In reply to Jeremy's tweet, that underscore is 3x smaller (simpler?) than Lodash! https://twitter.com/jashkenas/status/568564455937839106

Apparently, it's only true if you use <script> tag, but if you use lodash's module feature and build your project with browserify(or webpack) you get different numbers. In simple cases underscore can be 4-6 times bigger.

15020 bundle-lodash-without.js
 4820 bundle-lodash-without.min.js
 1647 bundle-lodash-without.min.js.gz
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.js$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
echo $files | xargs eslint

Harry Roberts has written an epic article where he suggests breaking down classes into objects (o-), components (c-), utilities (u-), themes (t-), states (is-, has-) and a couple of others (_, js-, qa-). He uses this namespacing method to make the code he writes more readable and maintainable at scale.

I've got a slightly different take on it. I would argue that Harry's method of adding class types adds complexity to our CSS. With BEM naming conventions and Sass I believe

#!/usr/bin/python
## gitsh (pronounced like "glitch"), an interactive wrapper for git.
##
## gitsh parses the output of "git status" and numbers the files for
## you, for easy operations on multiple files.
##
## $ gitsh status
## 1) M foo/bar.py
## 2) M foo/baz.py
## 3) A blah.sh

Sometimes a Controller is Just a Controller

Abstract

You grok SOLID. You practice TDD. You've read Sandi's book…twice. You rewatch Destroy All Software monthly. You can pronounce GOOS. You know your stuff!

But some of your coworkers say your code is too complex or confusing for them. You might rush to conclude that must be a them problem.

But doubt lingers: what if they're right?

@ichim-david
ichim-david / latency.txt
Last active September 11, 2015 08:43 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@ichim-david
ichim-david / collect_articles.py
Created September 25, 2015 17:45 — forked from rothnic/collect_articles.py
Asyncio with ProcessPool to collect and process data about urls, using Newspaper
"""Collect article metadata and associate it with url dimension.
Currently the url dimension includes a domain and url, but there is
a higher level grouping that we care about. What is the outlet,
who authored the article, what kind of site is it, when was
it published, etc.
"""
import os