Skip to content

Instantly share code, notes, and snippets.

@wycats
wycats / app.js
Last active February 11, 2016 16:08
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});

build

Clone and build Node for analysis:

$ git clone https://github.com/joyent/node.git
$ cd node
$ export GYP_DEFINES="v8_enable_disassembler=1"
$ ./configure
$ make -j4
@voxpelli
voxpelli / SASS_Color_Contrast.md
Last active August 21, 2022 11:49
Pure SASS script for calculating contrast ratios of colors. MOVED TO: https://github.com/voxpelli/sass-color-helpers

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

@cybear
cybear / raspberry_pi_optimization.md
Last active January 27, 2023 22:17
I read up a little on performance optimization for the Raspberry Pi, and gathered the links before they disappear from my short term memory.

Raspberry Pi general optimization

  • Use a class 10 SD card for best speed. The USB bus can't come much higher than 30MB/s so you don't have to buy any extremely fast ones though. Not all cards are compatible, check the compatibility list: http://elinux.org/RPi_SD_cards
  • Use the HardFloat version of Raspbian instead of the SoftFloat. HF has much faster floating point operations - however SF is required for running Java. So it's either Java or performance, like normal.
  • The official Raspbian image gives low network speeds: http://elinux.org/RPi_Performance#NIC
  • A graphics driver by Simon / teh_orph is using hardware acceleration for some instructions: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=28294 installation instructions: http://elinux.org/RPi_Xorg_rpi_Driver
  • The firmware can be upgraded which gives, among other things, better GPU performance.
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@simme
simme / drupal_table_pager.php
Created August 23, 2012 11:51
Drupal table with pager from db_select()
<?php
/**
* Display point award report.
*
* Generates a list of awarded points.
*
* @return array $content
*/
function game_report_page_points() {
// For some mysterious reason only parts of the db_select API is chainable.
@simX
simX / hidpi.txt
Created July 28, 2012 04:58
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@rauchg
rauchg / ms.md
Created December 21, 2011 00:25
Milliseconds conversion utility.
@simme
simme / _mixins.sass
Created May 25, 2011 12:20
SASS Mixins
// Rounds all the corners of a box
@mixin border-radius($radius, $clip: padding-box)
-webkit-border-radius: $radius
-moz-border-radius: $radius
-o-border-radius: $radius
border-radius: $radius
-webkit-background-clip: $clip
-mox-background-clip: $clip
-o-background-clip: $clip
background-clip: $clip

A pure CSS bendy shadow:

I suspect that some trig calculations could make this very general.

bendy_shadow