Skip to content

Instantly share code, notes, and snippets.

View hlorand's full-sized avatar
👾

Loránd Horváth hlorand

👾
View GitHub Profile
@hlorand
hlorand / upload_image_contvert_base64.php
Created August 22, 2014 22:35
Uploads image and converts to base64
<?php
if(isset($_FILES['image']))
{
$file_name = $_FILES['image']['name'];
$file_array = explode(".", $file_name);
$file_ext = strtolower(array_pop($file_array));
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = pathinfo($file_tmp, PATHINFO_EXTENSION);
$file_data = file_get_contents($file_tmp);
@hlorand
hlorand / PonciuszPilatusz.js
Last active August 29, 2015 14:20
A sclipt lecseléli az összes "r" betűt "l" betűle.
/*
Lépa letek mogyoló, kolán leggel litkán likkant a ligó.
A sclipt lecseléli az összes "r" betűt "l" betűle.
*/
function ponciusz() {
var elements = document.querySelectorAll("body, body *");
var results = [];
var child;
for(var i = 0; i < elements.length; i++) {
@hlorand
hlorand / php_gd_png_opacity.php
Created July 24, 2015 00:40
PHP gd png image opacity filter function
function filter_opacity( &$img, $opacity ) //params: image resource id, opacity in percentage (eg. 80)
{
if( !isset( $opacity ) )
{ return false; }
$opacity /= 100;
//get image width and height
$w = imagesx( $img );
$h = imagesy( $img );
@hlorand
hlorand / cpu_limiter.sh
Created August 16, 2015 23:31
Script that limits application CPU usage on OSX
#!/bin/bash
#########################
# CPU LIMITER (for OSX) #
#########################
<<DESCRIPTION
The script limits an application CPU usage.
-------------------------------------------
You have to specify application PID (process id) and desired CPU usage percentage.
function mysqltable_to_htmltable($table) {
global $conn;
$result0 = mysqli_query($conn,'SHOW COLUMNS FROM '.$table) or die('cannot show columns from '.$table);
$result = mysqli_query($conn,'SELECT * FROM '.$table) or die('cannot show columns from '.$table);
if(mysqli_num_rows($result0) && mysqli_num_rows($result)) {
echo '<table cellpadding="5" cellspacing="0" border="1">';
@hlorand
hlorand / generate_rotated_images_1-360_degrees.sh
Last active April 16, 2016 20:21
Generates 360 pieces of image, each image rotated +1 degree (1st: 1degree, 2nd: 2degree ...) - Only OSX
#!/bin/bash
#usage: first parameter is the input image, example: "scipt.sh image.jpg"
WIDTH=$(sips $1 -g pixelWidth | tail -1 | grep -oE '[^ ]+$')
HEIGHT=$(sips $1 -g pixelHeight | tail -1 | grep -oE '[^ ]+$')
NEWWIDTH=$(echo \($WIDTH*1.5\)/1 | bc)
NEWHEIGHT=$(echo \($HEIGHT*1.5\)/1 | bc)
@hlorand
hlorand / google_maps_multiple_markers.html
Created May 16, 2016 13:08
Google Maps Multiple Markers Bare Minimum Code
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
@hlorand
hlorand / progress.html
Created September 25, 2016 07:40
jQuery reading position indicator progress bar
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
var getMax = function(){
@hlorand
hlorand / fadein_onscroll.htm
Created February 16, 2017 19:32
Fade in div on scroll
<html>
<head>
<style>
#container
{
height:2000px;
}
#container div
{
@hlorand
hlorand / RaspberryPiVideoRecord.sh
Created June 24, 2017 18:37
Video recording and streaming script for Raspberry Pi + Pi Camera
#!/bin/bash
#
# Video recording script for Raspberry Pi. Set bitrate and recording time below
#
# To autostart this script after login, edit /etc/xdg/lxsession/LXDE-pi/autostart and add the following line BEFORE "@xsreensaver":
#
# sh ./RaspberryPiVideoRecord.sh
#
# To convert the output .h264 file to mp4:
#