Skip to content

Instantly share code, notes, and snippets.

View dflima's full-sized avatar
📱
developing stuff

Danilo dflima

📱
developing stuff
View GitHub Profile
@dflima
dflima / die-dump.sublime-snippet
Last active May 3, 2017 20:23
Sublime Text snippet to dump and die. Trigger it with "dd + tab"
<snippet>
<content><![CDATA[
die(var_dump(\$${1:this}));
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dd</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
<?php
use Illuminate\Support\Arr;
function array_multi_search(array $array, $key)
{
if (!is_string($key)) {
return false;
}
@dflima
dflima / fix-git-author.sh
Created September 2, 2016 17:46
Fix name and email from an commit author and committer
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="<wrong-email>"
CORRECT_NAME="<correct-name>"
CORRECT_EMAIL="<correct-email>"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
@dflima
dflima / merge_branches.sh
Created August 30, 2016 10:48
Checkout to a base branch (master, develop etc.) and merges to your current branch
#!/bin/bash
function usage()
{
printf "Usage:\n\n"
printf "./merge_branches.sh <branch>\n\n"
}
if [ "$1" == "" ]; then
usage
@dflima
dflima / delete_merged_branches.sh
Last active July 8, 2017 02:50
Deletes branches merged with <branch>
#!/bin/bash
function usage()
{
printf "Usage:\n\n"
printf "./delete_merged_branches <branch>\n\n"
}
if [ "$1" == "" ]; then
usage
<?php
for ($i = 1; $i < 200; $i++) {
$a = load($i);
echo "You have allocated {$i}M (".memory_get_usage().") memory in this php script\n";
unset($a);
}
function load($i)
#!/bin/bash
echo "Enter number to be converted: "
read no
echo "Converting $no from decimal to binary (base2)"
no=`echo "obase=2;$no" | bc`
echo Binary: $no
echo "Converting binary($no) to decimal"
no=`echo "obase=10;ibase=2;$no" | bc`
f :: [Int] -> [Int]
f lst = map ((!!)lst) [1,3..length lst-1]
-- This part deals with the Input and Output and can be used as it is. Do not modify it.
main = do
inputdata <- getContents
mapM_ (putStrLn. show). f. map read. lines $ inputdata
f :: Int -> [Int] -> [Int]
f n arr = concatMap (replicate n) arr
-- This part handles the Input and Output and can be used as it is. Do not modify this part.
main :: IO ()
main = getContents >>=
mapM_ print. (\(n:arr) -> f n arr). map read. words