Skip to content

Instantly share code, notes, and snippets.

🐦
fly like a bird ...

Kcko

View GitHub Profile
View example.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="url_style.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function changeurl(url)
{
var new_url="/Your URL/"+url;
window.history.pushState("data","Title",new_url);
document.title=url;
View decorator-nette.php
<?php
# https://forum.nette.org/cs/31783-mazanie-suboru-po-samotnej-akcii-stiahnut-subor#p202279
use Nette\Application\Responses\FileResponse;
use Nette\Http\IRequest;
use Nette\Http\IResponse;
final class DownloadAndDeleteFileResponse implements Nette\Application\IResponse
{
private $response;
View fragment.txt
<tr>
<td rowspan=6 align="center" valign="middle"><font size=-2>1. KOLO</font></td>
<td align="center"><font size=-2>22.4.</font></td>
<td align="center"><font size=-2>17:00</font></td>
<td align="left"><font size=-2>BALKAN BOYS</font></td>
<td align="left"><font size=-2>FC FOFO</font></td>
<td align="right"><font size=-2><B>&nbsp;</B></font></td>
<td align="right"><font size=-2>&nbsp;</font></td>
<td align="left"><font size=-2>ODLOŽENO</font></td>
</tr>
View random-number-between.sql
-- For range (min..max( (min inclusive, max exclusive) it is:
FLOOR( RAND() * (max-min) + min )
-- For range (min..max) (min+max inclusive) it is:
FLOOR( RAND() * (max-min+1) + min )
View johny-ex.php
<?php
// For each flag, assign a power of two
// This makes a mask with a single bit turned on
$male = 1;
$bald = 2;
$tall = 4;
$funny = 8;
$fictitious = 16;
View permission.php
<?php
class Permissions {
const ADD_CONTENT = 0x1;
const ADD_OWN_CONTENT = 0x2;
const EDIT_CONTENT = 0x4;
const EDIT_OWN_CONTENT = 0x8;
const DELETE_CONTENT = 0x10;
@Kcko
Kcko / bitwise-permission-checking.php
Created Mar 22, 2019 — forked from phnah/bitwise-permission-checking.php
Check permission using bitwise operators
View bitwise-permission-checking.php
Initially, I found bitmasking to be a confusing concept and found no use for it. So I've whipped up this code snippet in case anyone else is confused:
<?php
// The various details a vehicle can have
$hasFourWheels = 1;
$hasTwoWheels = 2;
$hasDoors = 4;
$hasRedColour = 8;
@Kcko
Kcko / headings.scss
Last active Mar 8, 2019 — forked from paramburu/headings.scss
Sass recursive headings function (h1, h2, h3...)
View headings.scss
// orig source: https://guwii.com/bytes/sass-function-loop-headings-h1h2h3h4h5h6/
@function headings($from:1, $to:6) {
@if $from == $to {
@return 'h#{$from}';
} @else {
@return 'h#{$from},' + headings($from+1, $to);
}
}
View submitted-by.php
<?php
if ($form['submit']->isSubmittedBy()) {
// ...
}
or
if ($form->isSubmitted() === $form['submit']) {
// ...
}
You can’t perform that action at this time.