Skip to content

Instantly share code, notes, and snippets.

View derekstavis's full-sized avatar
🚀

Derek W. Stavis derekstavis

🚀
  • West Hollywood, California
View GitHub Profile
@derekstavis
derekstavis / Dereks-Guide-Arch-Linux.md
Last active June 18, 2018 18:22
Derek's guide to Arch Linux

Arch Linux is a GNU/Linux distribution that's always in the newest version of software packages, differing it from versionated distributions as Ubuntu and Debian, which updates all package's major/minor only in new releases. Another good point of Arch is that all configurations are the default ones, so you don't get Canonical's or RedHat's opinions in your operating system.

Although, not everything is flowers. Arch's installation isn't graphical, that's why I've created dsome time ago a sequence of commands to help friends to get Arch Linux with GNOME with the setup I consider the best for everyone.

After creating a boot thumb drive and boot it (download in https://www.archlinux.org/download/)

@derekstavis
derekstavis / cpfvalidate.py
Last active September 24, 2020 20:22
Validação de CPF em Python
def validate_cpf(cpf):
''' Expects a numeric-only CPF string. '''
if len(cpf) < 11:
return False
if cpf in [s * 11 for s in [str(n) for n in range(10)]]:
return False
calc = lambda t: int(t[1]) * (t[0] + 2)
d1 = (sum(map(calc, enumerate(reversed(cpf[:-2])))) * 10) % 11
@deiu
deiu / linkheaderparser.js
Last active July 25, 2019 11:34
Parse HTTP Link header in Javascript
// parse a Link header
//
// Link:<https://example.org/.meta>; rel=meta
//
// var r = parseLinkHeader(xhr.getResponseHeader('Link');
// r['meta'] outputs https://example.org/.meta
//
function parseLinkHeader(header) {
var linkexp = /<[^>]*>\s*(\s*;\s*[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*")))*(,|$)/g;
var paramexp = /[^\(\)<>@,;:"\/\[\]\?={} \t]+=(([^\(\)<>@,;:"\/\[\]\?={} \t]+)|("[^"]*"))/g;
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@tshirtman
tshirtman / test_rounded.py
Created September 6, 2013 15:44
Rounded rectangle implementation, this is a widget, should probably be converted to a canvas instruction
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ListProperty
from math import sin, cos, pi
kv = '''
BoxLayout:
FloatLayout:
RoundedBox:
@pezz
pezz / crypto-pi-root.md
Last active December 17, 2020 15:40
Archlinux ARM encrypted root

Intro

Just some FYI, to get started:

  • I'm using a 16 GB Sandisk SD card.
  • I have a model B Pi, 512 MB RAM (not really relevant, thought I'd mention it).
  • Monitor and keyboard connected to the Pi itself, for now.
  • Network working, internet access.
@joekiller
joekiller / gtk-firefox.sh
Last active October 21, 2021 04:15 — forked from phstc/gtk-firefox.sh
INSTALL FIREFOX ON AMAZON LINUX X86_64 COMPILING GTK+
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh
@derekstavis
derekstavis / DigitalClock.java
Created October 15, 2012 18:43
DigitalClock HH:MM for Android
package com.derekstavis;
public class DigitalClock extends TextView {
private int hours;
private int minutes;
private int seconds;
private Timer clockTimer;
private final TimerTask clockTask = new TimerTask() {
@Override

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@andrebras
andrebras / deploy.rb
Created January 11, 2012 16:29
Capistrano deploy.rb example (capistrano+passenger+rvm+bundler+git)
set :application, "sprai"
# RVM integration
# http://beginrescueend.com/integration/capistrano/
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, "1.9.2-p290"
set :rvm_type, :user
# Bundler integration (bundle install)