Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* PHP Quiz #1
*
* What is the function definition of hello()?
*
* function hello() {
* ...
* }
@atmoz
atmoz / post-receive
Created June 20, 2012 19:47
Git hook script for deploying code with push
#!/bin/bash
#
# Deploy on push. Use different strategies on different branches.
#
function deploy_branch() {
# set branch path
case "$1" in
"master")
export GIT_WORK_TREE=/home/web/example.com ;;
@atmoz
atmoz / post-receive
Created June 20, 2012 22:16
Git hook script in PHP for deploying code with push
#!/usr/bin/php
<?php
function deploy($branch) {
$branchPaths = array(
'master' => '/home/web/example.com',
'develop' => '/home/web/test.example.com'
);
if (array_key_exists($branch, $branchPaths)) {
@atmoz
atmoz / reply.txt
Created October 9, 2012 14:40
Longer comment on science and society
Ref. https://twitter.com/atmoz/status/255077724740276224
and the following discussion.
Quote: "The foundations of society should be built in the same way buildings
are – with scientific methods, not by voting for political parties."
First off all, by "foundations" I mean, for example (but not limited to), the
basic understanding for human needs and how to satisfy them. To expand my
analogy of buildings: we use science to determine the foundation before placing
walls. We need to know how much material we got, and calculate and distribute
@atmoz
atmoz / CustomModule.php
Created November 15, 2012 12:59
Register assets
<?php
class CustomModule extends CWebModule {
private $assetsUrl;
/**
* Publish assets by copying files to public assets folder,
* accessable by clients.
*/
<h1>My first post</h1>
<p>So this is how it looks</p>
<p>My second paragraph</p>
@atmoz
atmoz / change-wordpress-password.sh
Created February 28, 2015 21:29
A fun little script that changes wordpress passwords in a docker-compose setup with wordpress and mysql.
#!/bin/bash
dbContainer="db"
userTable="wordpress.users"
username=${1:-"admin"}
password=${2:-"$username"}
passwordHash=$(docker run --rm -it -v $(pwd)/www:/www php:5.4-cli php -r "\
include '/www/wp-includes/pluggable.php';\
define('ABSPATH', '/www/');\
@atmoz
atmoz / bad
Created April 7, 2015 11:40
if-else-nesting-hell
if (a) {
do A
if (b) {
do B
if (c) {
do C
}
else {
@atmoz
atmoz / junit
Last active April 23, 2022 23:13
JUnit Bash script - run JUnit tests with ease in CLI
#!/bin/bash
#
# NAME
# junit - run JUnit tests with ease
#
# USAGE
# junit [FILE... | CLASS... | DIR]
#
# EXAMPLES
# junit
@atmoz
atmoz / wlp3s0-eduroam
Created August 24, 2016 10:08
Working netctl profile for eduroam on the University of Bergen
Connection='wireless'
Interface=wlp3s0
Security='wpa-configsection'
Description="eduroam network"
IP='dhcp'
TimeoutWPA=30
WPAConfigSection=(
'ssid="eduroam"'
'key_mgmt=WPA-EAP'
'eap=PEAP'