Skip to content

Instantly share code, notes, and snippets.

View matiit's full-sized avatar
:octocat:

Mateusz Tracz matiit

:octocat:
View GitHub Profile
@matiit
matiit / random_integers.cpp
Created April 22, 2010 07:12
C++ generating random numbers
#include <ctime>
#include <cstdlib>
// W funkcji głównej trzeba zainicjalizowac generator liczb losowych
srand(time(NULL));
// widac losowanie
void wypeln_los(int *tab, int n, int min, int max){
for (int i=0;i<n;i++){
tab[i] = rand()%(max-min+1)+min;
@matiit
matiit / fibonacci
Created May 27, 2010 07:06
ciag fib rekurencyjnie i iteracyjnie
#include <cstdlib>
#include <iostream>
using namespace std;
double fibonacci(long long n){
if (n<2)
return 1;
else
return fibonacci(n-1)+fibonacci(n-2);
}
#include <algorithm>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
// Zgrabna funkcja do wypelniania tablicy losowymi liczbami
void wypeln_los(int *tab, int n, int min, int max){
@matiit
matiit / 30-keymap-misc.fdi
Created January 6, 2011 13:58
udev and hal keyboard files for samsung R530
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<!-- These are raw scancodes produced by the atkbd driver -->
<match key="@input.originating_device:info.linux.driver" string="atkbd">
<match key="/org/freedesktop/Hal/devices/computer:system.hardware.vendor" contains="BenQ">
<match key="/org/freedesktop/Hal/devices/computer:system.hardware.product" contains="Joybook R22">
@matiit
matiit / addToGroups.sh
Created February 27, 2011 18:43
script adds user to all groups in a system (Linux),
#!/bin/bash
echo "Podaj nazw? usera";
read USER_CHOICE;
for i in `cut -f1 -d':' "/etc/group"`; do
gpasswd -a $USER_CHOICE $i ;
done
@matiit
matiit / laravelTemplateForelse.blade.php
Created October 7, 2012 19:58
forelse in laravel template
<?php
/*
* Very nice and usefull!
*/
@forelse ($users as $user)
{{ $user->name }}
@empty
<p>There are no users.</p>
@endforelse
@matiit
matiit / update_from_different_database.sql
Created December 7, 2012 10:02
Updating table in different database
UPDATE
database1.table D1,
database2.table D2
SET D1.email=D2.email
WHERE D1.domain=D2.domain AND D1.email IS NULL AND D2.email <>'';
@matiit
matiit / loadSimple.php
Last active October 13, 2015 17:38
Checking for file existance, now code is running on older PHP versions too
/*
* loadSimpleFileToArray
*
* what the function does
*
* @param (String) path to the source file
* @return (Array)
*/
function loadSimpleFileToArray($fileName)
{
@matiit
matiit / stageDeleted.sh
Created December 20, 2012 13:49
stage deleted files in git repo
for x in `git status | grep deleted | awk '{print $3}'`; do git rm $x; done
@matiit
matiit / simple_vbulletin_crawler.py
Last active December 16, 2015 12:29
Nice using of exceptions to "break loop more than one level up"
#-*- coding: utf-8 -*-
from pyquery import PyQuery as pq
import MySQLdb
db = MySQLdb.connect(host="localhost", user="someuser",
passwd="somepassword", db="somedatabase", charset='utf8')
c = db.cursor()
# It explains itself
# Of course we can dig it from forum "programmaticaly",