Skip to content

Instantly share code, notes, and snippets.

View solidnerd's full-sized avatar
🦆

Niclas Mietz solidnerd

🦆
View GitHub Profile
@solidnerd
solidnerd / TextAreaMessageCounter.js
Last active August 29, 2015 14:01
Uses JQuery to count letters on a TextArea
var messageCount=0;
$(document).ready(onReady);
function onReady(){
$("input").powerTip({placement:'n'});
$("textarea").powerTip({placement:'n'});
$("textarea").keyup(function(){
if(messageCount < 160){
messageCount = $(this).val().length;
/*
* Transfer Object as per diagram
*/
public class CircleTransfer{
private int x;
private int y;
private int radius;
void setX(int x){
this.x=x;
}
@solidnerd
solidnerd / mysql_backup.sh
Last active August 29, 2015 14:17
Mysql Docker backup Script
#!/bin/sh
DATE=$(date +%d-%m-%Y)
MySQL_USER=""
MySQL_PASS=""
BACKUPNAME="mysql_"$DATE".sql"
docker exec mysql mysqldump -u$MySQL_USER -p$MySQL_PASS --all-databases > $BACKUPNAME
@solidnerd
solidnerd / currenttime.cs
Last active August 29, 2015 14:21
Helps to get the actual Time for Java.Date(long ...)
class Program {
static void Main(string[] args) {
DateTime Jan1st1970 = new DateTime(1970,1,1,0,0,0);
long diff = (long) (DateTime.Now.ToLocalTime() - Jan1st1970).TotalMilliseconds;
Console.WriteLine(diff);
}
}
@solidnerd
solidnerd / fun.erl
Created July 20, 2015 20:23
Fun Inception !
Fruit = [apple,pear,orange] .
MakeTest = fun(L) -> (fun(X) -> lists:member(X, L) end) end.
IsFruit = MakeTest(Fruit).
IsFruit(pear).
% result: true
IsFruit(apple).
% result: true
@solidnerd
solidnerd / shop.erl
Last active August 29, 2015 14:25
Lets go shopping in Erlang
% shop.erl
-module(shop).
-export([cost/1]).
cost(oranges) -> 5;
cost(newspaper) -> 8;
cost(apples) -> 2;
cost(pears) -> 9;
cost(milk) -> 7.
@solidnerd
solidnerd / elixir-version.zsh
Created December 8, 2015 07:28
Elixir Version in a PowerLevel9K Theme
prompt_elixir() {
local elixir_prompt="$(mix --version 2>/dev/null)"
[[ -z "${elixir_prompt}" ]] && return
ELIXIR_ICON=$'\uE1C3' # alchemist 
$1_prompt_segment "$0" "magenta" "white" "${elixir_prompt:4} $ELIXIR_ICON"
}
@solidnerd
solidnerd / install_elixir.md
Created May 15, 2016 15:31 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then kerl and exenv are your best friends.

@solidnerd
solidnerd / GitlabContainerRegistrySetup.md
Last active February 21, 2024 14:48
GitLab Container Registry Setup

Settting up a Container Registry with docker-gitlab

This should be used for new users to getting started with the container registry feature on docker-gitlab.

Requirements

@solidnerd
solidnerd / register-runner.sh
Created July 13, 2016 06:00
Get GitLab Runner Token Automatically
#!/bin/bash
http POST https://gitlab.com/ci/api/v1/runners/register.json token=<registration token> -b | jq .token