Skip to content

Instantly share code, notes, and snippets.

View skorotkiewicz's full-sized avatar
💻
Programming

Sebastian Korotkiewicz skorotkiewicz

💻
Programming
View GitHub Profile
@skorotkiewicz
skorotkiewicz / simsimi.php
Created December 8, 2016 15:22
SimSimi - php talking bot
<?PHP
function simsimi($tresc) {
$curl = curl_init(); if (!$curl) exit;
$headers = array(
'Accept: application/json, text/javascript, */*; q=0.01',
'Content-type: application/json; charset=utf-8',
'Referer: http://www.simsimi.com/talk.htm',
'User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; pl; rv:1.9.2.13) Gecko/20101203 Firefox/3.5.13',
'Cookie: sagree=true; JSESSIONID=9EC7D24A64808F532B1287FFDDCDEC44',
@skorotkiewicz
skorotkiewicz / trafficlights.ino
Created December 8, 2016 15:23
Arduino - Interactive Traffic Lights with button
int carRed = 12; // assign the car lights
int carYellow = 11;
int carGreen = 10;
int pedRed = 8; // assign the pedestrian lights
int pedGreen = 9;
int button = 2; // button pin
int crossTime = 5000; // time allowed to cross
unsigned long changeTime; // time since button pressed
void setup() {
pinMode(carRed, OUTPUT);
@skorotkiewicz
skorotkiewicz / ChristmasTree.ino
Created December 8, 2016 15:23
Arduino - Christmas Tree
long randNumber;
void setup() {
DDRB = B11111111;
DDRD = B11111100;
}
void loop()
{
for(int fadeValue = 0; fadeValue <= 255; fadeValue +=5) {
analogWrite(11, fadeValue);
delay(30);
@skorotkiewicz
skorotkiewicz / telnet_server.php
Last active January 25, 2020 20:36
PHP Telnet Server with commands
<?php
set_time_limit(0);
$socketMain = socket_create(AF_INET, SOCK_STREAM, 0) or die();
socket_set_option($socketMain, SOL_SOCKET, SO_REUSEADDR, 1) or die();
socket_bind($socketMain, '127.0.0.1', '1234') or die();
socket_listen($socketMain, 5) or die();
$clients = array();
while(true){
$read = array();
$read[0] = $socketMain;
@skorotkiewicz
skorotkiewicz / iso3166-1.php
Created December 8, 2016 15:25
ISO 3166-1 PHP Array
<?php
array(
"AX"=>"land Islands",
"AF"=>"Afghanistan",
"AL"=>"Albania",
"DZ"=>"Algeria",
"AS"=>"American Samoa",
"AD"=>"Andorra",
"AO"=>"Angola",
"AI"=>"Anguilla",
@skorotkiewicz
skorotkiewicz / back.html
Created December 8, 2016 15:25
back to top button
<!-- version: 1.3 (2013/12/01) - added lines: 46-51 (animated version) -->
<!-- version: 1.2 (2013/01/28) - edited line: 41 (added .stop) -->
<!-- ---------- HTML ---------- -->
..
<header>
...
<nav>..</nav>
...
</header>
...
@skorotkiewicz
skorotkiewicz / NewYear.sh
Created December 8, 2016 15:26
Countdown to new year
while [[ $(date +%Y) -ne 2013 ]];do figlet $(($(date -d 2013-01-01 +%s)-$(date +%s)));sleep 1;clear;done;figlet 'Happy New Year!'
@skorotkiewicz
skorotkiewicz / gist:e7e802c01e0c3a8b0abd10400b787294
Created December 8, 2016 15:27
Restore mysql root password on Debian/Ubuntu
If you don't remember the MySql root user's password, you can use this tip:
root@server:~# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
1) Debian has an user for manteinance jobs on mysql, and the credentials are saved on a file:
root@server:~# cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
@skorotkiewicz
skorotkiewicz / screenshot.sh
Created December 8, 2016 15:27
Screenshot with date and Countdown
#!/bin/sh
#Install: save code to /usr/bin/screenshot
#Usage: $ screenshot 5
# five for 5sec countdown
if [ $1 ]
then
scrot -cd $1 "%Y-%m-%d_`echo $(date +%H-%m-%S)`.png" -e 'mv $f /home/modinfo/shots/'
echo "Screenshot save in: /home/modinfo/shots/`echo $(date +%Y-%m-%d_%H-%m-%S)`.png"
else
scrot "%Y-%m-%d_`echo $(date +%H-%m-%S)`.png" -e 'mv $f /home/modinfo/shots/'
@skorotkiewicz
skorotkiewicz / md5.sh
Created December 8, 2016 15:28
Create md5 from string in Linux
#!/bin/sh
# How to install?
# nano /usr/bin/md5
# copy&paste this code to /usr/bin/md5
# chmod +x /usr/bin/md5
if [ $1 ]
then
hash="$(echo -n "$1" | md5sum )"
echo "$hash"
else