Skip to content

Instantly share code, notes, and snippets.

View amlang's full-sized avatar
🐢
Works on my machine

Alexander amlang

🐢
Works on my machine
View GitHub Profile
@amlang
amlang / move_pictures_to_date_sorted_folder.py
Last active October 3, 2018 13:12
Move pictures to date sorted folders
from __future__ import print_function
import os
import datetime
for file in os.listdir("."):
if os.path.isfile(file) and (file.endswith('ARW') or file.endswith('jpg') or file.endswith('JPG') or file.endswith('xmp')) :
stat = os.stat(file)
created = stat.st_birthtime
dt = datetime.datetime.fromtimestamp(tt)
year = d.year
@amlang
amlang / index.html
Last active June 3, 2018 14:10
Material-Design Typography scss
<html lang="en" dir="ltr">
<head>
<title>Mat-Typo</title>
<meta key="viewport" name="viewport" content="initial-scale=1.0, width=device-width, shrink-to-fit=no" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<p class='mat-h4'> Material Design - Typography example</p>
<p class="mat-body1"> More information can be found in the documentation under
@amlang
amlang / GetRandomCharacter.rb
Last active May 22, 2018 14:09
ruby - Get random character except 'F' and 'T'
#!/usr/local/bin/ruby -w
puts ( ['A'..'Z'].map(&:to_a) # create field with characters A-Z
.flatten - ["F", "T"] # reduce nesting level and exclude 'F' and 'T'
)[rand(23)] # take a random value from the remainung 24 letters
@amlang
amlang / gist:b9d60889ce9d13b51aa02bcde5b4b50b
Created January 17, 2018 09:28 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@amlang
amlang / foreach_arraywalk_test.php
Created March 22, 2016 11:54
A test to determine whether foreach or array_walk is faster
<?php
// A test to determine whether foreach or array_walk is faster
$foretimes = 0;
for($i=0; $i < 10000; $i++){
$test = array_fill(0, 10000, 'test_data');
$start = microtime(true);
@amlang
amlang / angular-ui-sref-if.js
Last active March 22, 2016 11:57
Conditional control structure for ui.router states
/**
* Conditional control structure for ui.router states
*
* usage in js:
* angular.module('myModuel',['ui.router','ui-sref-if') ......
*
* usage in view:
* <a ui-sref=".nextstate" ui-sref-if="!myForm.$invalid">Next State</a>
*
* sass:
@amlang
amlang / find json key value pair regex
Last active September 29, 2022 03:23
Regex find key and value pair in JSON formated string
# PHP / Ruby
# Regex find key and value pair in JSON formated string
# Match 1: Key
# Match 2: Value
# https://regex101.com/r/zR2vU9/4
# http://rubular.com/r/KpF3suIL10
# http://stackoverflow.com/questions/14349889/how-to-use-a-regular-expression-to-extract-json-fields/35129815#35129815
(?:\"|\')(?<key>[^"]*)(?:\"|\')(?=:)(?:\:\s*)(?:\"|\')?(?<value>true|false|[0-9a-zA-Z\+\-\,\.\$]*)
@amlang
amlang / generatePassword.php
Last active August 29, 2015 14:04
PHP - Method generates a random password
/**
* Method generates a password
* @param int $length length of password
* @param int $strength
* 0 - Password with random case-sensitive characters and digits (standard set of 64 characters
* 1 - Password will be generated of a extended set of 88 characters
* @return string the generated password
*/
public function generatePassword($length=8, $strength=1) {
$password = '';
//IIFE
(function(window, $) {
//on document ready
$(function() {
//Gets A-Elements `href` attr. and add `active`-class to parents LI-Element
$('a[href="' + window.location.pathname + '"]').parent("li").addClass('active');
});
})(window, window.jQuery);