Skip to content

Instantly share code, notes, and snippets.

View decima's full-sized avatar
🐙
Lecturing

decima

🐙
Lecturing
View GitHub Profile
function calculate_median($arr) {
$count = count($arr); //total numbers in array
$middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value
if($count % 2) { // odd number, middle is the median
$median = $arr[$middleval];
} else { // even number, calculate avg of 2 medians
$low = $arr[$middleval];
$high = $arr[$middleval+1];
$median = (($low+$high)/2);
}
@danielestevez
danielestevez / gist:2044589
Last active June 30, 2024 09:04
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@77web
77web / 1_security.yml
Created February 25, 2013 07:23
How to switch user accounts between two(or more) different firewalls when using Symfony\Bundle\SecurityBundle
//you may have some more configs here...
providers:
user:
entity: { class: MyAppBundle:User, property: loginEmail }
admin:
entity: { class: MyAppBundle:Admin, property: username }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
@Stoffo
Stoffo / http_statuscodes.php
Last active October 26, 2017 11:24
PHP Array with alle HTTP Status Codes
<?
$http_codes = array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
@decima
decima / ducks.sh
Last active May 1, 2024 16:26
Small CLI Tool which lists biggest top 10 files/folders
#!/bin/sh
du -hsx ${1:-.}/* | sort -rh | head -10
#!/bin/bash
# Install ZSH and Oh-my-ZSH
if [ ! -d "$HOME/.oh-my-zsh" ]; then
if [[ `uname` == "Darwin" ]]; then
brew update
brew install zsh
else
sudo apt update
sudo apt install zsh
@Akhu
Akhu / Future.kt
Last active December 24, 2021 10:51
🎄 New Year Code 2022
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
import kotlin.random.Random
class Celebration(val year: Int, val stillWithCovid: Boolean = false) {
override fun toString(): String {
return "Bonnes fêtes & bonne année ${this.year} ! 🎉 " + (if (stillWithCovid) "On va encore avoir pas mal de covid 🦠" else "⛑ Ca va aller mieux !")
}