Skip to content

Instantly share code, notes, and snippets.

View gseguin's full-sized avatar

Ghislain Seguin gseguin

  • Boulder, CO
  • 04:01 (UTC -06:00)
View GitHub Profile

Using the classnames.bind method

Many people who work with React are familiar with the excellent classnames library. If you aren't familiar, it provides a simple function for gluing classnames together. In web programming in general, there are many times that we need to add or remove multiple classes based on conditional logic. The classnames library makes this easy.

More and more developers are embracing CSS Next and the power of CSS modules. However, when you add CSS modules to your react components, working with classnames gets more difficult. Typically, CSS modules is implemented with class name mangling. Transforming human readable class name strings into unique identifiers helps ensure that every class name in your app is unique.

This means that you can write your component CSS in isolation without worrying about the dreaded class name collisions that have plagued CSS

@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@jhs
jhs / hello.js
Created April 6, 2012 00:41
Safe Javascript semicolons
var http = require('http');;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
http.createServer(function (request, response) {;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
response.writeHead(200, {'Content-Type': 'text/plain'});;;;;;;;;;;;;;;;;;;;;;;
response.end('Hello World\n');;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
}).listen(8124);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
console.log('Server running at http://127.0.0.1:8124/');;;;;;;;;;;;;;;;;;;;;;;;;
$(function($){
var depjson,
builderhtml = [],
sortable = [],
groupBy = function( jsondata ) {
var newarray = [];
for (key in jsondata) {
console.log( key );
}
// JS Today
function List() {
this.list = [].slice.call(arguments);
}
List.prototype.diff = function( array ) {
return array.filter(function(item) {
return !~this.list.indexOf(item);
}, this);
@cowboy
cowboy / ba-detach.js
Created April 23, 2011 16:43
JavaScript detach: detach a node from the DOM, optionally reattaching it when done.
/*!
* JavaScript detach - v0.2 - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function detach(node, async, fn) {
@cowboy
cowboy / lock-screen.sh
Created April 21, 2011 17:13
OS X: Start screensaver + lock screen (bind to a hotkey with a utility, or run via Launchbar / QuickSilver)
#!/bin/bash
sleep 0.5 && open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
@kriszyp
kriszyp / response.http
Created March 3, 2011 18:05
Server response of the future?
HTTP/1.1 200 OK
Content-Type: application/foo+json; # Web applications typically do and should use JSON as the semantic data source
# If your mobile device has an app for "application/foo+json", auto-launch app to handle resource
Link: <http://foo.com/ui.html>; rel="renderer" # HTML page to use to renderer it
Link: <http://foo.com/ui.ipa>; rel="ios.renderer" # Recommended device-specific app for this resource
Link: <http://foo.com/schema>; rel="describedby" # schema describing the JSON structure so that search engines can crawl it
...