Skip to content

Instantly share code, notes, and snippets.

View Swader's full-sized avatar
🏠
Buidling

Bruno Škvorc Swader

🏠
Buidling
View GitHub Profile
@Swader
Swader / sample.sql
Created February 14, 2014 01:22
Sample DB with test table and three sample rows
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
DROP SCHEMA IF EXISTS `sample` ;
CREATE SCHEMA IF NOT EXISTS `sample` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `sample` ;
-- -----------------------------------------------------
-- Table `sample`.`test`
@Swader
Swader / class.ziparchive.php
Last active August 29, 2015 13:56
Agbonghama Collins' code for image scraper article
<?php
class ZipImages
{
private $folder;
private $url;
private $html;
private $fileName;
private $status;
@Swader
Swader / FW Survey 2015.js
Last active August 29, 2015 13:56
Alternative embed code for Typeform, lets you use hidden fields in embed mode without server side tweaks. Relies on a #tf_container div being present in the body somewhere.
var formurl = "https://sitepoint.typeform.com/to/NfTGuu";
var formtitle = "Most Popular PHP Framework, 2015";
var tid = setInterval( function () {
if ( document.readyState !== 'complete' ) return;
clearInterval( tid );
var tfcon = document.getElementById('tf_container');
var el;
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {

Keybase proof

I hereby claim:

  • I am swader on github.
  • I am swader (https://keybase.io/swader) on keybase.
  • I have a public key whose fingerprint is FE15 423A 76B1 E9EA 4413 C91D 8339 09E8 D48B B7CC

To claim this, I am signing this object:

@Swader
Swader / npmsucks.php
Created August 23, 2014 11:01
NPM recursive installation fix
<?php
$moduleName = getMissingModule();
while ($moduleName !== false) {
echo 'Installing '.$moduleName.'.\n';
shell_exec('npm install '.$moduleName.' --no-bin-link');
$moduleName = getMissingModule();
}
function tryRun() {
@Swader
Swader / a.php
Created March 22, 2015 12:48
todoist_sample.php
$a = array(
0 => array(
'indent' => 1,
'name' => 'Inbox',
'color' => '#dddddd',
'is_deleted' => 0,
'collapsed' => 0,
'inbox_project' => true,
'archived_date' => null,
'item_order' => 0,
@Swader
Swader / qprw.php
Created June 14, 2015 10:42
qprw.php
$function = new Twig_SimpleFunction('qprw', function (array $replacements) {
parse_str($_SERVER['QUERY_STRING'], $qp);
foreach ($replacements as $k => $v) {
$qp[$k] = $v;
}
return '?'.http_build_query($qp);
});
@Swader
Swader / requirements.txt
Last active August 29, 2015 14:27
Requirements for PIP on ReadTheDocs
Babel==2.0
CommonMark==0.5.4
Jinja2==2.8
MarkupSafe==0.23
PyYAML==3.11
Pygments==2.0.2
Sphinx==1.3.1
sphinxcontrib-phpdomain==0.1.4
alabaster==0.7.6
argh==0.26.1
@Swader
Swader / Test
Created April 19, 2012 17:33
Trying out cocode.io
namespace cocode;
class Cocode {
private $_sMsg;
public function __construct($sMsg = '') {
if (!empty($sMsg)) {
$this->setMessage($sMsg);
}
}
@Swader
Swader / zf2selectDemo.php
Created September 10, 2012 16:44
ZF2 : Populating a select element
// Using Zend\Select form element
$oSelect = new Select('someName');
$oSelect->setAttribute('id', 'mySelect')->setLabel('This is a select box');
$aData = array(
'Option 1' => 'value1',
'Option 2' => 'value2',
array('label' => 'Option 3', 'selected' => true, 'value' => 'value3') // For default selection
);