Skip to content

Instantly share code, notes, and snippets.

@hazelement
hazelement / dropbox_git.md
Created December 31, 2015 17:34 — forked from trey/dropbox_git.md
Using Dropbox to Share Git Repositories

Using Dropbox to Share Git Repositories

First, create a Git subfolder inside your Dropbox folder. Then you can share the individual projects inside that folder with whomever you want (or just use it for instant offsite backups).

From inside a Git project:

git clone --bare . ~/Dropbox/Git/gitproject.git
git remote add dropbox ~/Dropbox/Git/gitproject.git

When you're ready to push:

@hazelement
hazelement / python_iterrate.py
Last active September 3, 2018 22:17
Python iterrate
# pandas dataframe
for index, row in df.iterrows():
print row['c1'], row['c2']
# dictionary
for key, value in d.iteritems():
print(key, value)
@hazelement
hazelement / Docker setup notes
Last active February 21, 2019 21:03
Docker example
## Steps to install docker on brand new machine
1. Install docker and docker-compose
* `apt-get install docker docker-compose`
* `yum install docker docker-compose`
2. Add certain user to docker group, `usermod -aG docker $USER`
3. Direct docker to save cache to a specific location, modify `daemon.json` following the `daemon.json` notes.
4. If SElinux is enabled, issue this command to allow docker to access sepecified location `chcon -R -t svirt_sandbox_file_t /SOURCEDIR`
@hazelement
hazelement / user.sql
Created September 5, 2018 20:28
Postgres
/* create user with password */
CREATE USER xxx WITH ENCRYPTED PASSWORD 'xxxxxxx';
/* set permissions */
GRANT CONNECT ON DATABASE mydb TO xxx;
GRANT USAGE ON SCHEMA public TO xxx;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO xxx;
@hazelement
hazelement / site.conf
Last active November 13, 2018 22:52
Nginx
http {
server {
// redirect all to 443
listen 80 default server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
@hazelement
hazelement / abstract_class.py
Last active September 13, 2018 16:10
Python class
# python 2
from abc import abstractmethod, ABCMeta
ABC = ABCMeta('ABC', (object,), {'__slots__': ()})
class AbstractClassExample(ABC):
@abstractmethod
def do_something(self):
pass
@hazelement
hazelement / cryptokitties.sol
Created October 24, 2018 02:39 — forked from arpit/cryptokitties.sol
Cryptokitties Contract from the Eth blockchain
pragma solidity ^0.4.11;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@hazelement
hazelement / .tmux.conf
Last active April 23, 2020 04:33
machine_config
# Uncomment the lines with the options you want to activate (by deleting the preceding "#")
# Allow mouse interaction
set-option -g mouse on
# Change prefix key to CTRL+A. "C-" stands for CTRL, "M-" stands for ALT key
set-option -g prefix C-k
unbind C-b
bind C-k send-prefix
@hazelement
hazelement / launch.json
Last active January 15, 2019 23:23
VSCode setting for C/C++ Project
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"type": "cppdbg",
"request": "launch",
@hazelement
hazelement / executable-CMakeLists.txt
Last active January 16, 2019 23:42
Cmake Examples
cmake_minimum_required(VERSION 2.8.9)
project (TestLibrary)
#For the shared library:
set ( PROJECT_LINK_LIBS libtestStudent.so )
link_directories( ~/exploringBB/extras/cmake/studentlib_shared/build )
#For the static library:
#set ( PROJECT_LINK_LIBS libtestStudent.a )
#link_directories( ~/exploringBB/extras/cmake/studentlib_static/build )