Skip to content

Instantly share code, notes, and snippets.

View h4cc's full-sized avatar

Julius Beckmann h4cc

  • ZENNER IoT Solutions
  • Hamburg, Germany
View GitHub Profile
@h4cc
h4cc / elixir_symbols.md
Last active March 25, 2024 13:00
All symbols used in the elixir programming language

Symbols used in Elixir

A list of all not symbols and notations of elixir. Tried to have a base for comparision for other programming languages.

Operators

  • === (strict)
  • !== (strict)
  • == (relaxed)
@h4cc
h4cc / struct_matching.exs
Created July 28, 2017 07:34
Example how matching on elixir structs will make code more robust and refactorable with less possible errors at runtime.
# This is our struct with some fields.
defmodule User do
defstruct name: "julius", role: :user
end
defmodule UserManager do
# Matching on %User{} will ensure we will get a user.
@h4cc
h4cc / imgur_fetch_gallery.php
Created February 18, 2016 20:34
Downloading all images from a imgur gallery with a simple PHP Script.
@h4cc
h4cc / satis_install.sh
Last active February 13, 2024 16:39
Guide to install a satis server for composer. It can mirror packages and create a index for own packages.
# Install a Webserver
apt-get -y install apache2
# Target docroot to /home/satis/web/
# Install PHP5 CLI and needed programs.
apt-get -y install php5-cli php5-curl php5-json git wget
# Add a specifix user for our task
adduser satis
@h4cc
h4cc / install_tl_wn722n.sh
Created July 3, 2017 08:53
Installing a TP-Link TL-WN722N V2 on Ubuntu 16.04 with Kernel 4.4
# Source: https://askubuntu.com/questions/912498/tl-wn722n-is-not-recognized
sudo apt-get install git dkms git make build-essential
cd /usr/src
sudo git clone https://github.com/lwfinger/rtl8188eu.git
sudo dkms add ./rtl8188eu
sudo dkms build 8188eu/1.0
sudo dkms install 8188eu/1.0
sudo modprobe 8188eu
@h4cc
h4cc / satis_github_auth.sh
Created November 27, 2013 17:50
Some notes on how to authenticate with composer/satis against github oauth, so the rate limit of 60 will be raised op to 5000. Can also be used for travis-ci.
# Create a new Token
curl -u 'githubuser' -d '{"note":"Your Application"}' https://api.github.com/authorizations
# It is: "ebab4dc37e654bb230a9c69ebcd5f38e9a81e210"
#{
# "created_at": "2013-01-04T18:00:28Z",
# "app": {
# "url": "http://developer.github.com/v3/oauth/#oauth-authorizations-api",
@h4cc
h4cc / howto.md
Last active November 28, 2022 12:53
Getting Thumbnails / Previews of your RAW files in Ubuntu

Howto

Install these programms

sudo apt-get install gnome-raw-thumbnailer ufraw-batch

Try now if everything works, and your thumbnails show up. If not, try the following part.

@h4cc
h4cc / Makefile
Created April 25, 2022 12:48
Ubuntu 22.04 Jammy Jellyfish - Basic packages i usually install
#
# Ubuntu 22.04 (Jammy Jellyfish)
#
# Basic packages i usually install.
#
# Author: Julius Beckmann <github@h4cc.de>
#
# Upgraded Script from 18.04: https://gist.github.com/h4cc/c54d3944cb555f32ffdf25a5fa1f2602
# Upgraded Script from 17.04: https://gist.github.com/h4cc/09b7fe843bb737c8039ac62d831f244e
@h4cc
h4cc / phpunit_mock_iterator_items.php
Created September 18, 2013 10:56
A helper function for creating Iterator Mocks with PHPUnit. Simply add the expected items to the prepared mock.
<?php
/**
* @author Julius Beckmann <github@h4cc.de>
* @license MIT (http://opensource.org/licenses/MIT)
*/
/**
* Adds expected items to a mocked Iterator.
*/
function mockIteratorItems(\Iterator $iterator, array $items, $includeCallsToKey = false)
@h4cc
h4cc / UrlGenerator.php
Created July 30, 2013 13:15
How to add a _url default to routes, so a external url can be generated by name.
<?php
namespace Acme\DemoBundle\Routing\Generator;
use Symfony\Component\Routing\Generator\UrlGenerator as BaseUrlGenerator;
class UrlGenerator extends BaseUrlGenerator
{
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens)
{