Skip to content

Instantly share code, notes, and snippets.

@romainl
romainl / git-jump
Last active January 10, 2024 16:47
git-jump hack that can be used FROM Vim
#!/bin/sh
usage() {
cat <<\EOF
usage: git jump <mode> [<args>]
Jump to interesting elements in an editor.
The <mode> parameter is one of:
diff: elements are diff hunks. Arguments are given to diff.
@lifeart
lifeart / component.js
Created February 6, 2020 14:42
Ember Cp Validations Octane
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import Object from "@ember/object";
import { reads } from "@ember/object/computed";
import { validator, buildValidations } from "ember-cp-validations";
import { getOwner } from "@ember/application";
const Validations = buildValidations({
billing_first_name: {
descriptionKey: "form.fields.billing_first_name",
@pkoppstein
pkoppstein / combine.jq
Last active August 5, 2021 02:13
a commutative and associative operator for combining two JSON objects
# This gist defines a jq filter for combining two JSON objects by resolving conflicts
# in a way that is appropriate for mapping relational tables to objects.
# "combine" as defined here is both commutative and associative.
# Example:
# { "id": 123, "son": "Son1", "surname": "S"}
# | combine({ "id": 123, "son": "Son2", "surname": "S"})
# produces: { "id": 123, "son": ["Son1",Son2], "surname": "S"}
# Combine two entities in an array-oriented fashion.
@jfsiii
jfsiii / .block
Last active July 20, 2016 01:49
SVG colored patterns via masks/CSS without images
license: unlicense
@bgrins
bgrins / detectDataURL.js
Last active December 18, 2023 18:57
Detect if a string is a data URL. Doesn't try to parse it or determine validity, just a quick check if a string appears to be a data URL. See http://jsfiddle.net/bgrins/aZWTB/ for a demo.
// Detecting data URLs
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2
function isDataURL(s) {
return !!s.match(isDataURL.regex);
}
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i;
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@twasink
twasink / Description
Created June 6, 2012 11:55
Spring, Hibernate, HSQLDB and automatically creating tables
An example of using Spring and Hibernate together to automatically create a HSQLDB in-memory database for testing hibernate mappings.
@cs278
cs278 / dovecot-maildir-compress.sh
Created December 17, 2011 15:52
Compresses email in maildir format
#!/bin/sh
# Find the mails you want to compress in a single maildir.
#
# Skip files that don't have ,S=<size> in the filename.
#
# Compress the mails to tmp/
#
# Update the compressed files' mtimes to be the same as they were in the original files (e.g. touch command)
#

Building a Facebook application with Rails and hosting it in Heroku

Introduction

Facebook has given a big step in simplicity with its Graph API and the creation of the Open Graph protocol, now more than ever it's easier to read and write data from and to the socalled social graph.

You could turn your webpage into a fully-featured Facebook-like page, just like if you were inside Facebook, you can give your users the ability to sign in with their Facebook credentials, customize your users' experience with parameters taken from their Facebook profiles, you could add a Like button to every object in your page as images, songs, articles, etc., tell your users which friends of theirs have liked your content, and a lot of things more, oh, I forgot to mention something, all of this with total ease. Yes, I know you could do it with Facebook Connect, but I said "with ease".