This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
require 'benchmark' | |
COUNT = 10_000_000 | |
NAME = "Test Name" | |
EMAIL = "[email protected]" | |
class Person | |
attr_accessor :name, :email | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary_search(array, key, from = nil, to = nil) | |
return nil if array.empty? | |
to ||= array.size - 1 | |
from ||= 0 | |
return nil if from > to or ( from == to and array[from] != key ) | |
mid_idx = (from + to) / 2 | |
if key == array[mid_idx] | |
return mid_idx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFLAGS = -g -Wall | |
all : problem_7 | |
problem_7 : problem_7.c | |
$(CC) $(CFLAGS) -o $@ $< -lm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_result); | |
Intent intent = getIntent(); | |
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |