Skip to content

Instantly share code, notes, and snippets.

@xaviervia
xaviervia / README.md
Last active February 16, 2021 20:12
Sketch 43 files JSON types
# 10_basic.py
# 15_make_soup.py
# 20_search.py
# 25_navigation.py
# 30_edit.py
# 40_encoding.py
# 50_parse_only_part.py
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active April 21, 2024 02:41
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@philfreo
philfreo / _README.md
Last active February 3, 2022 20:46
How to do conditional statements in Close.io template tags
@donnfelker
donnfelker / CircularTransformation.java
Last active December 2, 2020 20:47
Picasso and CircularTransform Example
import android.graphics.*;
import com.squareup.picasso.Transformation;
/**
* Transforms an image into a circle representation. Such as a avatar.
*/
public class CircularTransformation implements Transformation
{
int radius = 10;
@mikeseif
mikeseif / DesaturateInterpolator
Last active August 29, 2015 14:06
Desaturate the given Color int by the ratio provided, 1.0f for full saturation, 0.0f for max desaturation. Edit the minimum value of 0.2f (or add as an additional param) to alter how low the desaturation can go.
/**
* Desaturate the given color int value by the provided ratio, down to a minimum of 0.2f.
*
* Note: Do not pass R.color ints, resolve the actual color int via
* getResources().getColor(R.color.your_color_name_here).
*
* f(x) = ( startSaturation / 1.0f * ratio ) + ( minSaturation * (1.0f - ratio) )
*
* @param int The color value to desaturate
* @param float The ratio to desatrate by (0.0f - 1.0f)
@hopsoft
hopsoft / db.rake
Last active April 3, 2024 13:13
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@nguyenhuy
nguyenhuy / Activity.java
Last active January 2, 2016 16:49
Show a badge on top of an ABS's MenuItem, using BadgeView from https://github.com/jgilfelt/android-viewbadger.
private BadgeView mBadgeView;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.badge_demo, menu);
MenuItem menuItem = menu.findItem(R.id.item_id);
ImageButton iconView = new ImageButton(this, null,
com.actionbarsherlock.R.style.Widget_Sherlock_ActionButton);
iconView.setImageDrawable(menuItem.getIcon());