Skip to content

Instantly share code, notes, and snippets.

###Edit this file

/etc/nginx/nginx.conf

###Add this line anywhere inside the http { } block:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

###Go to your Forge panel and restart Nginx

@rofr
rofr / transcript.txt
Created September 7, 2015 14:43
redis - the machine language of databases
INCR next_user_id //returns 1000
HMSET user:1000 name bart password ¤¤¤hash¤¤¤
HSET users bart 1000
ZADD followers:1000 1401267618 1234
ZADD following:1234 1401267618 1000
INCR next_post_id => 10343
HMSET post:10343 user 1000 time $time body ’Ay Caramba’
RPUSH posts:1000 10343
@r38y
r38y / abstract.rb
Created November 12, 2010 17:49
How to declare which methods should be defined in a subclass of an abstract class
module Abstract
def abstract_methods(*args)
args.each do |name|
class_eval(<<-END, __FILE__, __LINE__)
def #{name}(*args)
raise NotImplementedError.new("You must implement #{name}.")
end
END
end
end
/*
---
name: guilloche
script: guilloche.js
description: guilloche
provides: [Guilloche]
...
*/
(function($){
var insertAtCaret = function(value) {
if (document.selection) { // IE
this.focus();
sel = document.selection.createRange();
sel.text = value;
this.focus();
}
else if (this.selectionStart || this.selectionStart == '0') {
var startPos = this.selectionStart;
@nateberkopec
nateberkopec / secure_headers.rb
Created March 28, 2013 19:44
Example of a simple Rack middleware for scrubbing your Rack headers of sensitive information.
class Rack::SecureHeaders
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
response = @app.call(env)
# [status, headers, response] = response
$ = jQuery
TIMEOUT = 20000
lastTime = (new Date()).getTime()
setInterval ->
currentTime = (new Date()).getTime()
# If timeout was paused (ignoring small
# variations) then trigger the 'wake' event
if currentTime > (lastTime + TIMEOUT + 2000)
@dlo
dlo / prefixes.sql
Last active November 25, 2021 03:26
PostgreSQL procedure that concatenates all prefix substrings for a given string. Helpful for generating full-text search indices.
CREATE FUNCTION prefixes(varchar, integer) RETURNS varchar AS $$
DECLARE
result varchar;
minlength integer;
BEGIN
SELECT GREATEST($2, 0) INTO length;
WITH RECURSIVE t(value, n) AS (
SELECT $1, length($1)
UNION ALL
SELECT substring(value for n-1), n-1 FROM t WHERE n>minlength
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?