Skip to content

Instantly share code, notes, and snippets.

View vojty's full-sized avatar
🦦

Tomáš Vojtášek vojty

🦦
View GitHub Profile
@vojty
vojty / update.php
Last active August 29, 2015 13:59
Apache Solr 4.0+ Update document
<?php
// https://wiki.apache.org/solr/UpdateJSON
$data = array(
array(
'id' => $id,
'field' => array(
'set' => 'value', // set is keyword
)
)
);
@vojty
vojty / nginx.vhost
Last active August 29, 2015 14:00
AngularJS HTML5 mode + Nginx + socket.io
server {
listen 80
server_name example
location / {
root /var/www/your/app;
if (!-e $request_filename){ # handles page reload
rewrite ^(.*)$ /views/index.html break;
}
index /views/index.html;
}
<?php
namespace Avdily;
use Nette;
class TemplateHelpers extends Nette\Object {
/** @var string */
private $wwwDir;
@vojty
vojty / opendkim
Last active August 29, 2015 14:17
Nastavení DKIM - ./script domena.cz
#!/bin/bash
# http://linuxaria.com/howto/using-opendkim-to-sign-postfix-mails-on-debian
#
# Note:
# opendkim-genkey has been changed (-h sha256)
redColor='\033[0;31m'
greenColor='\033[0;32m'
noColor='\033[0m'
@vojty
vojty / phantomjs
Last active August 29, 2015 14:18 — forked from deviantony/phantomjs
#! /bin/sh
# Init. script for phantomjs, based on Ubuntu 12.04 skeleton.
# Author: Anthony Lapenna <lapenna.anthony@gmail.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Phantomjs service"
NAME=phantomjs
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
@vojty
vojty / backup.sh
Created June 17, 2015 14:53
MySQL backups
#!/bin/bash
now=$(date +"%Y-%m-%d")
mysqlUser="root"
mysqlPass="xxx"
server="user@server.com"
log="./backup_sql.log"
@vojty
vojty / User.php
Last active November 25, 2015 14:29 — forked from Ocramius/User.php
Doctrine ManyToMany Setters
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@vojty
vojty / download.sh
Created August 28, 2015 13:16
Let's get excited
#!/bin/bash
youtube-dl --extract-audio --audio-format "mp3" --audio-quality 1 --batch-file "list.txt"
@vojty
vojty / multiply.js
Created November 6, 2016 14:51
Large numbers multiplication
function mul(num1, num2) {
// Convert to array of string in reverse order (right to left calc)
num1 = `${num1}`.split('').reverse();
num2 = `${num2}`.split('').reverse();
// Init empty array
const d = [];
for(let i = 0; i < num1.length + num2.length; i++) {
d[i] = 0;
@vojty
vojty / branfuck.js
Created November 12, 2016 18:11
Brainfuck.js
function branfuck(code, input){
const output = [];
const data = [];
let dataPointer = 0;
let inputPointer = 0;
let inputArr = input.split('').map(i => i.codePointAt(0))
const chars = code.split('');
let codePointer = 0;