Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊

António Almeida promatik

🌊
View GitHub Profile
@promatik
promatik / relation_table.blade.php
Created Jul 29, 2018
Backpack CRUD Relation table
View relation_table.blade.php
<?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 / territories.sql
Last active Feb 20, 2020
Portuguese Administrative Area (Distritos, concelhos e freguesias Portuguesas)
View territories.sql
--
-- 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 / ajax.js
Created Jan 16, 2018
Javascript AJAX call
View ajax.js
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 Nov 28, 2017
HashMap vs Object variable cast performance test
View Main.java
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 Apr 24, 2017
Laravel Blade Translate Snippet Shortcut
View BladeTranslate.sublime-snippet
<snippet>
<content><![CDATA[
{{ __("$TM_SELECTED_TEXT") }}
]]></content>
<tabTrigger>t</tabTrigger>
<scope>text.blade.php</scope>
</snippet>
@promatik
promatik / A.markdown
Created Dec 4, 2016
Sublime Text 3 - Twilight Sidebar Theme
View A.markdown

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 Sep 22, 2016 — forked from adrexia/styles.less
Atom - hide file icons and replace arrows
View styles.less
.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 / Penalty shootout.js
Created Apr 12, 2016
Check whenever penalty shootout game is finished or not
View Penalty shootout.js
// --------------------
// 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));
}
// --------------------
@promatik
promatik / A.markdown
Last active Dec 4, 2016
Sublime Text 2 Twilight Sidebar Theme
View A.markdown

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 / guessing-game
Created May 26, 2015
Guessing Game Simulator
View guessing-game
function guessingGame(testcases, useMidPoint) {
useMidPoint = useMidPoint || false;
var correct = i = 0,
r = Math.random;
for (i=testcases;i;i--) {
var a = r(), b = r(), k = useMidPoint ? 0.5 : r();
correct += (k < a && a > b) || (k > a && a < b);
}
You can’t perform that action at this time.