Skip to content

Instantly share code, notes, and snippets.

View bikemule's full-sized avatar

bikemule

  • Kraken Technologies
  • Brooklyn, NY
View GitHub Profile
@alekseykulikov
alekseykulikov / index.md
Last active April 14, 2024 00:32
Principles we use to write CSS for modern browsers

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@guillaumepiot
guillaumepiot / test_image_upload.py
Last active January 22, 2024 19:19
Django Rest Framework - Image/File upload test
import os
import io
from PIL import Image
from django.core.urlresolvers import reverse
from django.conf import settings
from rest_framework import status
from rest_framework.test import APITestCase
@dkarchmer
dkarchmer / aws-lambda-picture-resize
Created May 20, 2016 04:12
Sample JavaScript code for resizing pictures on AWS Lambda
/**
* This is based on: http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-s3-events-adminuser.html
*/
// dependencies
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm').subClass({ imageMagick: true }); // Enable ImageMagick integration.
var util = require('util');
var MAX_WIDTH;
@carljm
carljm / envsettings.py
Created April 13, 2016 19:07
Django settings from env.
"""Utility for pulling settings from the environment."""
import os
from urllib.parse import urlparse
class EnvParser:
"""Utility for getting settings from the OS environ.
Instantiate with the name of an env var to get the current mode from (that
env var should be set to one of VALID_MODES, or not set), then call the
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@KeyMaster-
KeyMaster- / polarWarp.glsl
Created April 4, 2015 21:27
Cartesian to Polar coordinates warp shader, for shadertoy.com
//To be used on shadertoy.com
//Uses the image at iChannel0 and warps it into polar coordinates
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 relativePos = fragCoord.xy - (iResolution.xy / 2.0);
vec2 polar;
polar.y = sqrt(relativePos.x * relativePos.x + relativePos.y * relativePos.y);
polar.y /= iResolution.x / 2.0;
polar.y = 1.0 - polar.y;

docs

To start godoc at log in time (so it always there on port 6060 when you need it):

  1. copy smarticus.godoc.plist to in ~/Library/LaunchAgents
  2. launchctl load ~/Library/LaunchAgents/smarticus.godoc.plist
  3. visit http://localhost:6060
import numpy as np
import pandas as pd
import datetime
import urllib
from bokeh.plotting import *
from bokeh.models import HoverTool
from collections import OrderedDict
## Read in our data. We've aggregated it by date already, so we don't need to worry about paging
@equaliser
equaliser / gist:5194456
Created March 19, 2013 08:18
Arduino MCP4922 SPI DAC demo code
/*
MCP4922 test
Steve Woodward, 2010
most code borrowed from
http://mrbook.org/blog/2008/11/22/controlling-a-gakken-sx-150-synth-with-arduino/
connections
====================================================
+5v > 4922 pin 1
@snipe
snipe / goatse
Created March 14, 2013 08:03
Goatse ASCII art that won't break your W3C validation. (The original used double-hyphens inside the HTML comment, which would not validate.)
<!--
* * * * * * * * * * * * * * * * * * * * * * * * *
* *
* / \ \ / \ *
*| | \ | | *
*| `. | | : *
*` | | \| | *
* \ | / / \\\ ____ \\ : *
* \ \/ ___~~ ~____| \ | *
* \ \__~ ~__\ | *