Skip to content

Instantly share code, notes, and snippets.

@drocarmo
drocarmo / menu.js
Created January 24, 2014 06:01
A smooth mobile menu transition for multiple nav options
// Requires
// jQuery JavaScript Library v1.10.2
// &
// jQuery Easing v1.3
$("a.menu").click(function(event) {
event.preventDefault();
var icon = $(this).find(".icon-menu");
if ($(icon).is(".open")) {
$(".menu,.sub-menu").slideUp(300, "easeInQuint");
@palexander
palexander / ruby_data_object_comparison.rb
Created January 24, 2014 05:49
Benchmark to compare hash, OpenStruct, struct, and classes in Ruby
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "[email protected]"
class Person
attr_accessor :name, :email
end
@jun1st
jun1st / binary_search
Created January 8, 2014 06:50
binary search
@mlgill
mlgill / dropboxsetup.py
Created January 8, 2014 02:57
dropboxsetup: iOS (Pythonista), attempts to handle Dropbox auth token creation and login seamlessly
import dropbox, os, webbrowser
# A generic Dropbox module to create a token and login.
# Michelle L. Gill, 2014/01/06
# To use:
# import dropboxsetup
# sess, client = dropboxsetup.init(TOKEN_FILENAME, APP_KEY, APP_SECRET)
# TOKEN_DIRECTORY can be set to store tokens in a folder, set to "Tokens" by default
@mrbcuda
mrbcuda / currency.png
Last active December 29, 2018 05:28
A mashup of financial turbulence and regime switching examples having missing bits into a standalone example without missing bits. Uses sources from Quantivity and Systematic Investor blogs as well as the CRAN RHmm and TTR packages. Uses quantmod and FRED as a data source. The turbulence calculation clearly is not the same as referenced original…
currency.png
@yomimono
yomimono / Makefile
Last active January 2, 2016 01:39
An implementation of the Sieve of Eratosthenes, which answers the the question "what is the nth prime?", as long as n is <= 10001.
CFLAGS = -g -Wall
all : problem_7
problem_7 : problem_7.c
$(CC) $(CFLAGS) -o $@ $< -lm
@cwsaylor
cwsaylor / Default (OSX).sublime-keymap
Last active January 2, 2016 01:38
Install Package Control, All Autocomplete, Better CoffeeScript, CoffeeScriptHaml, Git, Ruby Slim, Sass
[
{ "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"}
]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
@creack
creack / gist:8231109
Created January 3, 2014 01:45
gpg key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFHkTBIBCAC44rjXDaIH0OeBdke1Sbowxse/4b9n/bLPAfY14jYOS7CEYQan
Ia5KeIzONsKzNXfyFBkx8wQ+3plB8zMQvf6xXqFsR2AalXpBUf/02fGebDPmGgRZ
ghl8gVVXlanYxxlC6GMt0QZy/6vbCrXYliE9kAhhLKZ8RlNT4xYDYjJahEAEM+fc
dXcjXp7znKRzVVkcgNDiOExiYiJNYRqF39mnLswl0IVHo9uRzE+Eu1QOIBoyq6v3
ZSyH3wGpHTfiW3ywZbHDbQRCLwSOKJDKjGosI4VDrIJZGPFiCDin2i4q58ddd0pe
xIH0pWshHHXotJFRJjaSWI1S9zi/5eH4Au+/ABEBAAG0M0d1aWxsYXVtZSBKLiBD
aGFybWVzIDxndWlsbGF1bWUuY2hhcm1lc0Bkb2NrZXIuY29tPokBOAQTAQIAIgUC
Upi/wgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQsz5GQstuP/MwFgf/
This is the most restrictive and safest way I've found, as explained here for hypothetical ~/my/web/root/ directory for your web content:
For each parent directory leading to your web root (e.g. ~/my, ~/my/web, ~/my/web/root):
chmod go-rwx DIR (nobody other than owner can access content)
chmod go+x DIR (to allow "users" including _www to "enter" the dir)
sudo chgrp -R _www ~/my/web/root (all web content is now group _www)
chmod -R go-rwx ~/my/web/root (nobody other than owner can access web content)
chmod -R g+rx ~/my/web/root (all web content is now readable/executable/enterable by _www)
All other solutions leave files open to other local users (who are part of the "staff" group as well as obviously being in the "o"/others group). These users may then freely browse and access DB configurations, source code, or other sensitive details in your web config files and scripts if such are part of your content. If this is not an issue for you, then by all means go with one of the simpler solutions.