Skip to content

Instantly share code, notes, and snippets.

View promatik's full-sized avatar
🌊

António Almeida promatik

🌊
View GitHub Profile
@promatik
promatik / territories.sql
Last active February 20, 2020 09:16
Portuguese Administrative Area (Distritos, concelhos e freguesias Portuguesas)
--
-- Table Structure
--
CREATE TABLE `territories` (
`id` varchar(6) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL,
`level` enum('1','2','3') COLLATE utf8mb4_unicode_ci NOT NULL,
`parent_id` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@promatik
promatik / relation_table.blade.php
Created July 29, 2018 14:48
Backpack CRUD Relation table
<?php
if($field['value'] == "")
return;
$crud->route = $field['route'];
?>
<div @include('crud::inc.field_wrapper_attributes') >
<h3 style="margin-top:0">{!! $field['label'] !!}</h3>
<div class="array-container form-group">
@promatik
promatik / ajax.js
Created January 16, 2018 11:59
Javascript AJAX call
ajax = (url, data, success, error, method) => {
var params = typeof data == 'string' ? data : Object.keys(data).map(
k => encodeURIComponent(k) + '=' + encodeURIComponent(data[k])
).join('&');
if(method === undefined)
method = "POST";
var xhr = new XMLHttpRequest();
xhr.open(method, url);
@promatik
promatik / Main.java
Last active November 28, 2017 17:46
HashMap vs Object variable cast performance test
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
new Main();
}
@promatik
promatik / BladeTranslate.sublime-snippet
Last active April 24, 2017 16:35
Laravel Blade Translate Snippet Shortcut
<snippet>
<content><![CDATA[
{{ __("$TM_SELECTED_TEXT") }}
]]></content>
<tabTrigger>t</tabTrigger>
<scope>text.blade.php</scope>
</snippet>
@promatik
promatik / A.markdown
Last active December 4, 2016 21:27
Sublime Text 2 Twilight Sidebar Theme

This re-styles your sublime text sidebar to be dark, it fits default Twilight theme.

Twilight sidebar

Save the Default.sublime-theme file into packages/Theme - Default, make a backup of your original if you want to be able to go back easily.

Based on:

@promatik
promatik / A.markdown
Created December 4, 2016 21:16
Sublime Text 3 - Twilight Sidebar Theme

This re-styles your sublime text 3 sidebar to be dark, it fits default Twilight theme.

Twilight sidebar

Go to Menu > Preferences > Browse Packages, save the Default.sublime-theme file into the "User" folder.

Based on:

@promatik
promatik / styles.less
Last active September 22, 2016 22:53 — forked from adrexia/styles.less
Atom - hide file icons and replace arrows
.tree-view {
.icon:before {
display:none;
}
.list-group li:not(.list-nested-item), .list-tree li:not(.list-nested-item), .list-group li.list-nested-item > .list-item, .list-tree li.list-nested-item > .list-item {
line-height: 21px;
}
.list-group .selected:before, .list-tree .selected:before {
height: 21px;
}
@promatik
promatik / pt-PT.php
Created April 6, 2013 03:08
UserCake v2.0.2 pt-PT - Portuguese Language Translation
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
Portuguese Translation
*/
/*
%m1% - Dymamic markers which are replaced at run time by the relevant index.
*/
@promatik
promatik / Penalty shootout.js
Created April 12, 2016 22:39
Check whenever penalty shootout game is finished or not
// --------------------
// Penalty Shoot-out
// Ilustrated example at https://jsfiddle.net/promatik/yo00Lr4e/
// --------------------
function checkPenaltyShootOutEnd(round, score1, score2, total_rounds, first_shooter) {
return Math.abs(score1-score2) > (round > total_rounds ? round % 2 : Math.ceil((10-round) / 2) - (first_shooter ^ score1 < score2 ? 0 : round % 2));
}
// --------------------