Skip to content

Instantly share code, notes, and snippets.

View aeksco's full-sized avatar
🚀

Alexander Schwartzberg aeksco

🚀
View GitHub Profile
@jfriedlaender
jfriedlaender / gist:1273614
Created October 9, 2011 12:19
Lighten or darken a hexadecimal color (string)
# Amount should be a decimal between 0 and 1. Lower means darker
def darken_color(hex_color, amount=0.4)
hex_color = hex_color.gsub('#','')
rgb = hex_color.scan(/../).map {|color| color.hex}
rgb[0] = (rgb[0].to_i * amount).round
rgb[1] = (rgb[1].to_i * amount).round
rgb[2] = (rgb[2].to_i * amount).round
"#%02x%02x%02x" % rgb
end
@caleywoods
caleywoods / application.coffee
Created January 24, 2012 14:57
Backbone JS / Fullcalendar
$ ->
Event = Backbone.Model.extend()
Events = Backbone.Collection.extend({
Model: Event,
url : 'events'
})
EventsView = Backbone.View.extend({
initialize: ->
@christophermanning
christophermanning / README.md
Last active March 30, 2023 04:24
Voronoi Diagram with Force Directed Nodes and Delaunay Links

Created by Christopher Manning

Summary

Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.

The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.

Controls

@Jxck
Jxck / .gitignore
Created August 14, 2012 07:33
markdown rendering using Github API by ruby
readme.md
rendered.html
remain.txt
@yethee
yethee / app.foomodule.bar.js
Created September 15, 2012 19:47
Prototype of lazy-load a module of Marionette
App.module("FooModule.Bar", {
startWithApp: false,
define: function() {
// Code of submodule
}
});
@maxivak
maxivak / resize_nocrop_noscale
Last active September 24, 2024 09:17
Crop and resize an image using MiniMagick in Ruby on Rails. Two approaches.
def resize_nocrop_noscale(image, w,h)
w_original = image[:width].to_f
h_original = image[:height].to_f
if w_original < w && h_original < h
return image
end
# resize
image.resize("#{w}x#{h}")
@bravoecho
bravoecho / flattener.rb
Created November 28, 2012 13:16
flatten nested hash - recursive vs non-recursive
require 'pry'
data = {
a: {
alfa: "alfa",
beta: "beta"
},
b: 2,
c: {
alfa: {
@0xjjpa
0xjjpa / chrome.md
Created December 9, 2012 04:37
Understanding Google Chrome Extensions

#Introduction

Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.

Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.

Table of Contents

  1. Understand the Chrome Architecture
  2. Understand the Tabs-Extension Relationship
  3. Picking the right interface for the job
@focusaurus
focusaurus / ep_app.js
Last active June 14, 2022 00:06
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
const express = require("express");
const router = express.Router();
router.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = router;
@cleure
cleure / teensy-nes-gamepad.c
Last active April 21, 2021 13:28
More advanced NES / SNES to USB adapter, using a Teensy 2.0 board. Controller type can now be auto-detected, and there's an option to translate button presses to either USB Joystick or USB Keyboard events.
#include <stdint.h>
// GPIO pins used for connected gamepad
#define CLOCK 21
#define LATCH 20
#define DATA 19
#define DEVICE_TYPE_AUTO 0
#define DEVICE_TYPE_NES 1
#define DEVICE_TYPE_SNES 2