Skip to content

Instantly share code, notes, and snippets.

@letsspeak
letsspeak / database.yml
Created October 30, 2012 17:41
Redmine on unicorn on nginx with mysql, my configuration files.
# Default setup is given for MySQL with ruby1.8. If you're running Redmine
# with MySQL and ruby1.9, replace the adapter name with `mysql2`.
# Examples for PostgreSQL and SQLite3 can be found at the end.
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: ******
@jbottigliero
jbottigliero / select.jsx
Created December 16, 2013 04:29
React <select> Component (JSX)
/** @jsx React.DOM */
define(['reactjs'], function(React){
return React.createClass({
getDefaultProps: function(){
return {
multiple: false
/*
name: 'mySelect'
@rdunlop
rdunlop / rubocop_pre_commit_hook
Last active May 5, 2017 08:31
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified. Itself passes rubocop with default settings.
#!/usr/bin/env ruby
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/
# to prevent code injection: system is a dangerous call
def raise_single_quote_error
raise ArgumentError, 'Single quotes are not allowed in filenames here.'
end
@fversnel
fversnel / SmartSortable.js
Created December 30, 2014 11:36
React SmartSortable
var cloneWithProps = React.addons.cloneWithProps;
var SmartSortable = React.createClass({
getDefaultProps: function() {
return {component: "ul", childComponent: "li"};
},
render: function() {
var props = jQuery.extend({}, this.props);
@petehunt
petehunt / React sortable
Created December 9, 2013 22:30
Here's an example of React + jQuery UI sortable. The key thing to note is that we have the render() method do absolutely nothing and use componentDidUpdate() + React.renderComponent() to proxy updates through to the children. This lets us manage the DOM manually but still be able to use all the React goodies you know and love.
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
@ozkatz
ozkatz / ec2_ssh_config.py
Created June 21, 2013 00:50
generate an ~/.ssh/config file from your EC2 instances, so that you'd never have to lookup those fugly ec2-xx-xx-xx-xxx.compute-1.amazonaws.com hostnames again. Use your instance name instead!
#!/usr/bin/env python
import os
import sys
import argparse
try:
from boto.ec2.connection import EC2Connection
except ImportError:
sys.stderr.write('Please install boto ( http://docs.pythonboto.org/en/latest/getting_started.html )\n')
sys.exit(1)
@jchild3rs
jchild3rs / gist:470be49a4bc4caf3ca8a
Last active April 8, 2020 15:54
Hologram Gulp Plugin
/*
// Usage:
gulp.task('docs', function(cb) {
gulp.src('path/to/your/src')
.pipe(hologram(cb));
});
*/
var gulp = require('gulp'),
notify = require('gulp-notify'),
@equivalent
equivalent / README.md
Last active December 16, 2021 16:34
String "false" to_bool ... or how to convert Rails/SimpleForm radio buttons to boolean

This gist was writen in 2012 and it was solving specific problem in Rails & SimpleForm. Some fellow developers were pointing out this may be out dated concept. That's why I advise everyone to read comment section bellow to have a full grasp of alternative solutions

other sources that may be helpful to understand why this may not be best idea:

@mpeteuil
mpeteuil / rubocop_pre_commit_hook
Created August 3, 2013 17:44
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@HereChen
HereChen / convert-image-to-base64.js
Last active March 29, 2022 11:31
convert image to base64
/**
* version1: convert online image
* @param {String} url
* @param {Function} callback
* @param {String} [outputFormat='image/png']
* @author HaNdTriX
* @example
convertImgToBase64('http://goo.gl/AOxHAL', function(base64Img){
console.log('IMAGE:',base64Img);
})