Skip to content

Instantly share code, notes, and snippets.

View dflima's full-sized avatar
📱
developing stuff

Danilo dflima

📱
developing stuff
View GitHub Profile
<?php
$handle = fopen ("php://stdin", "r");
$arr_temp = fgets($handle);
$arr = explode(" ",$arr_temp);
$arr = array_map('intval', $arr);
sort($arr, SORT_NUMERIC);
$first_a = $last_a = $arr;
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);
for ($i = 1; $i <= $n; $i++) {
print str_repeat(' ', $n-$i);
print str_repeat('#', $i);
print PHP_EOL;
}
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);
$arr_temp = fgets($handle);
$arr = explode(" ",$arr_temp);
$arr = array_map('intval', $arr);
$count = count($arr);
<?php
$handle = fopen('php://stdin', 'r');
fscanf($handle, '%d', $n);
$a = [];
for ($i = 0; $i < $n; $i++) {
$temp = fgets($handle);
$a[] = explode(' ', $temp);
array_walk($a[$i], 'invtal');
#!/bin/bash
for user in $@; do
now=$(date +"%Y-%m-%d")
uid=$(id -u $user)
# Lock user account
passwd -l $user
tar -zcvf /home/dflima/$user.$uid.$now.tar.gz /home/$user
# Kill user session
@dflima
dflima / find_and_copy.sh
Created July 5, 2017 15:55
Encontra todos os arquivos pertencentes ao usuário "d.lima", que tenham sido modificados nos últimos seis dias e copia, mantendo a estrutura de diretórios, para o diretório "/home/d.lima/xavier_files"
find /srv/dev_data/xavier/ -type f -user "d.lima" -mtime -6 -exec cp --parents --target-directory=/home/d.lima/xavier_files/ {} \;
@dflima
dflima / find_replace.sh
Created April 6, 2017 15:00
find and replace "dev" with "test"
find . -name ".env" -exec sed -i s/dev/test/g {} \;
@dflima
dflima / rename.sh
Last active November 6, 2017 20:52
Git alias to rename local and remote branches
# Put the code below on your .gitconfig file, under "alias" section.
# Usage:
# git rename old_branch_name new_branch_name
[alias]
rename="!f() { git branch "$2" origin/"$1" && git push origin --set-upstream "$2" && git push origin --delete "$1"; }; f"
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 1,
"caret_style": "blink",
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Tomorrow.tmTheme",
"enable_tab_scrolling": false,
"fade_fold_buttons": false,
<?php
function fib(int $n) : int
{
return $n <=1 ? $n : fib($n-1) + fib($n-2);
}