Skip to content

Instantly share code, notes, and snippets.

View cahva's full-sized avatar

Markku Virtanen cahva

View GitHub Profile
@cahva
cahva / external_efiles_loginform.php
Last active August 29, 2015 14:01
eFiles external login form
<?php
$filerunUrl = 'https://efiles.fi';
$filerunLoginUrl = $filerunUrl.'/?action=login';
$redirectOnFailureUrl = 'http://localhost:8080/index.php?';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Efiles login</title>
@cahva
cahva / formatFileSIze.php
Created June 4, 2014 10:42
Format bytes to B,KB,MB,GB or TB
function formatFileSize($size)
{
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
for ($i = 0; $size > 1024; $i++) { $size /= 1024; }
return round($size, 2).$units[$i];
}
@cahva
cahva / gmaps_seo.js
Created June 17, 2014 08:40
Gmaps seo asemat
var seo_asemat = [{"id":"191","lat":"59.97799","lng":"23.434307","name":"Eken\u00e4s G\u00e4sthamn Ab","addr":"Pohjoinen Rantakatu 6","city":"10600 Tammisaari","info":"Veneasema","phone":"019-2411790","cellphone":"","email":"","www":"","company_name":"Sandn\u00e4s kauppa ja kahvila osuuskunta"},{"id":"51","lat":"64.763360","lng":"25.547891","name":"SEO Ala-Temmes","addr":"Jyv\u00e4skyl\u00e4ntie 69","city":"91930 Ala-Temmes","info":"<p>- laadukkaat tarvikkeet koira- ja hevosharrastajille[br]- l&auml;hikauppa[br]- kahvio[br]- veikkaus, toto<\/p>\n<p>&nbsp;<img src=\"http:\/\/asiakas2.devnet.fi\/www.seo.fi\/kuvat\/googlemapsikonit\/seo-jakeluasema.jpg\" alt=\"\" width=\"50\" height=\"50\" \/><img src=\"http:\/\/asiakas2.devnet.fi\/www.seo.fi\/kuvat\/googlemapsikonit\/seo-kahvio.jpg\" alt=\"\" width=\"50\" height=\"50\" \/><img src=\"http:\/\/asiakas2.devnet.fi\/www.seo.fi\/kuvat\/googlemapsikonit\/seo-automaattiasema.jpg\" alt=\"\" width=\"50\" height=\"50\" \/><\/p>","phone":"08 384 629","cellphone":"","email"
@cahva
cahva / curl_helper.php
Created August 1, 2014 06:31
curl_post helper
<?php
if (!function_exists('curl_post'))
{
function curl_post($url, array $post = NULL, array $options = array())
{
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $url,
@cahva
cahva / transcript.sh
Last active October 31, 2018 14:44
Get transcript from downloaded transcript json file
#!/usr/bin/env sh
jq '.results.transcripts[0].transcript' -r < ~/Downloads/asrOutput.json > transcript.txt
@cahva
cahva / videoplayerpause.html
Last active November 14, 2018 07:27
videoplayer pause
<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
@cahva
cahva / videosync-changeprivacypolicytext.html
Last active February 18, 2019 08:35
Change priv policy text
<script>
/* wait for element to be ready and then change text */
function tryEl(e) {
var privEl = document.querySelector('.video-player');
if (!privEl) {
window.requestAnimationFrame(tryEl);
} else {
@cahva
cahva / fortuneBasicServer.js
Created January 9, 2019 16:01
Fortune basic server
const http = require('http')
const fortune = require('fortune')
const fortuneHTTP = require('fortune-http')
const recordTypes = {
user: {
name: String,
enemies: [ Array('user') ]
}
}
@cahva
cahva / embed_youtube_to_event.html
Last active February 18, 2019 09:05
Embed script to add youtube video to videosync event
<script>
/* wait for element to be ready and then add embedded youtube */
function tryEl(e) {
var privEl = document.querySelector('.video-player');
if (!privEl) {
window.requestAnimationFrame(tryEl);
} else {
changeText(privEl);
<script>
function tryEl(e) {
var privEl = document.querySelector('#bitmovinplayer-video-bitmovin-player');
if (!privEl) {
window.requestAnimationFrame(tryEl);
} else {
removeBackground(privEl);
}