Skip to content

Instantly share code, notes, and snippets.

View jorgedfbranco's full-sized avatar

Jorge Branco jorgedfbranco

  • Zurich, Switzerland
View GitHub Profile
#include <stdio.h>
// Problem 1
// https://projecteuler.net/problem=1
void main() {
int sum = 0;
int i;
for (i = 3; i < 1000; ++i)
if (i % 3 == 0 || i % 5 == 0)
sum += i;
<!DOCTYPE html>
<html>
<head>
<title>Register Account</title>
<script>
function form_submit() {
alert('submitting!')
}
</script
</head>
History:
--all searches over the entire repository instead of only in the current branch
- git log --oneline (compressed, one line for commit)
- git log --grep <regex> (searches for commits with the given regex expression in their message)
- git log -Smysearchstring (searches for all the commits that contain any change for mysearchstring in this branch, that is, it looks at
files contents, not to commit messages.)
- git log --pretty=format:"%Cgreen%h %Cred%cn %Cblue%s"
  - git log --pretty=format:"%<|(20) %Cgreen%h %Cred%cn %Cblue%s" (with column)
http://i.stack.imgur.com/BlpRb.png
whatis / whereis / which
ls
red results -> broken symlink
Get return value of last executed command: echo $?
F2 / SHIFT+F2 -> Next / Previous error in the currently opened file
CTRL + F12 -> View file's methods
CTRL + (SHIFT +) E -> Recently (edited) files
SHIFT, SHIFT -> Search everywhere
sbt update-classifiers <- download all javadoc/sources for all dependencies
http://www.newlyswissed.com/top-6-most-unique-roads-in-switzerland/
http://www.myswitzerland.com/en-ch/top_attracties/
http://www.expatica.com/ch/out-and-about/Top-10-places-to-visit-in-Switzerland_102301.html
http://www.myswitzerland.com/en-ch/interests/excursion-summer/zoos-wildlife-parks/nocturama-tropical-gardens2.html
Jorge's Linux Cheat Sheet
Terminal's Shortcuts (full list @ http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/):
CTRL+A - Move the caret to the beginning of line.
CTRL+E - Move the caret to the end of line.
CTRL+U - Remove all the chars between the current caret position and the beginning of the line.
ALT+B - Move to the beginning of the previous word.
ALT+F - Move to the beginning of the next word.
CTRL+W - Delete word before cursor.
CTRL+D - Close shell if the current line is empty or delete current char.

Bash Cheat Sheet

curl

  • Pass in username/password: -u username:password, to use github tokens, curl -u 2346b76ab68d28071961d15e96e89d09614bec97:x-oauth-basic
  • Passing in HTTP headers: -h "A: B", such as -h "Autorization: bearer ABC
  • Post a message in the body of curl: --data "contents" or -d "contents"
  • curl will by default assume it's dealing with a GET, unless a -d is passed in, then being considered a POST. To explicitly state which request method you want, you can pass in -X PUT, -X HEAD, etc.
  • Follow redirects: -L
  • Avoid reporting download information: -s
  • Extra information: -v, -i
public static List<Integer> rabinKarp(String s, String p) {
int ph = 0;
for (int i = 0; i < p.length(); i++) {
char c = p.charAt(i);
ph = ph*31 + c;
}
List<Integer> results = new ArrayList<>();
int sh = 0;
for (int i = -p.length()+1; i < s.length()-p.length()+1; i++) {