Skip to content

Instantly share code, notes, and snippets.

View marcusandre's full-sized avatar

Marcus André marcusandre

View GitHub Profile
@marcusandre
marcusandre / check.sh
Last active December 16, 2015 16:55
Serve static files using http.FileServer
mkdir files
echo "32c3 is coming!" > files/file.txt
nohup go run main.go > /dev/null &
curl localhost:8080/file.txt
@marcusandre
marcusandre / get-cb.js
Created November 9, 2015 20:52
get last argument from arguments list if it is a function
function dummy () {
var args = [].slice.call(arguments)
var fn = typeof args[args.length - 1] === 'function' ? args.pop() : null
// ...
}
@marcusandre
marcusandre / ostype.sh
Last active January 31, 2019 18:19
Get operating system as string identifier from $OSTYPE
#!/bin/sh
#
# get os type
#
get_os() {
if [ -z $OSTYPE ]; then
OSTYPE=$(uname | tr '[:upper:]' '[:lower:]')
fi
@marcusandre
marcusandre / ipv6_freebsd.md
Created November 1, 2015 17:34
Configure IPv6 on netcup.de FreeBSD Servers

IPv6 on FreeBSD

ifconfig_em0_ipv6="<IP>"
ifconfig_vtnet0_aliases="inet6 <IP> prefixlen 64"
ifconfig_vtnet0_ipv6="inet6 accept_rtadv"
ipv6_default_interface="em0"
ipv6_defaultrouter="fe80::1%em0"
rtsold_enable="YES"
@marcusandre
marcusandre / .gitignore
Created October 4, 2015 20:39
node module ignored files list
# files
.DS_Store
npm-debug.log
# folders
build/
coverage/
node_modules/
@marcusandre
marcusandre / tab.js
Last active October 10, 2015 10:57
Quickly open a link in a new tab
function openTab (url, method) {
var m = method || '_blank'
var w = window.open(url, m)
w.focus()
}
openTab('https://google.com/')
@marcusandre
marcusandre / inline-blocks.md
Created February 26, 2015 21:47
Correct inline-block elements
<div style="text-align: center;">
  <div class="inline-block">Element</div>
  <div class="inline-block">Element</div>
  <div class="inline-block">Element</div>
</div>
.inline-block {
@marcusandre
marcusandre / bubble_sort.go
Created February 6, 2015 10:34
Implementing Bubble Sort Algorithm in Go
package bubble
func sort(arr []int) {
for itemCount := len(arr) - 1; ; itemCount-- {
swap := false
for i := 1; i <= itemCount; i++ {
if arr[i-1] > arr[i] {
arr[i-1], arr[i] = arr[i], arr[i-1]
swap = true
}
@marcusandre
marcusandre / wp_replace.sql
Created January 2, 2015 16:35
replace wordpress database content when migrating.
update wp_options set option_value = replace(option_value,'http://old_domain.com','http://new_domain.com');
update wp_postmeta set meta_value = replace(meta_value,'http://old_domain.com','http://new_domain.com');
update wp_posts set post_content = replace(post_content,'http://old_domain.com','http://new_domain.com');
update wp_posts set guid = replace(guid,'http://old_domain.com','http://new_domain.com');
update wp_posts set pinged = replace(pinged,'http://old_domain.com','http://new_domain.com');
update wp_comments set comment_content = replace(comment_content,'http://old_domain.com','http://new_domain.com');
@marcusandre
marcusandre / grid.css
Created July 23, 2014 09:28
table based grid-system
@media (min-width: 37.5em) {
.row { width: 100%; display: table; table-layout: fixed; }
.col { display: table-cell; }
}