Skip to content

Instantly share code, notes, and snippets.

View Tomas2D's full-sized avatar
:octocat:

Tomáš Dvořák Tomas2D

:octocat:
View GitHub Profile
@thomascube
thomascube / vtimezone.php
Last active February 15, 2023 21:15
VTIMEZONE component for a Olson timezone identifier with daylight transitions.Solution to this StackOverflow question: https://stackoverflow.com/questions/6682304/generating-an-icalender-vtimezone-component-from-phps-timezone-value/25971680
<?php
use \Sabre\VObject;
// use composer autoloader
require_once 'vendor/autoload.php';
/**
* Returns a VTIMEZONE component for a Olson timezone identifier
* with daylight transitions covering the given date range.
@alexsasharegan
alexsasharegan / .htaccess
Created September 7, 2016 00:36
Apache Config for React Router
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@caike
caike / attack.md
Last active October 2, 2022 14:37
XSS attack demo with innerHTML

Tested with Chrome, Firefox and Safari.

The following code will not trigger an alert. target.innerHTML = "<script> alert('XSS Attack'); </script>";

The following code will trigger an alert. target.innerHTML = "";

@lahmatiy
lahmatiy / prevent-input.js
Last active May 22, 2023 17:19
Snippet for node.js to prevent any user input while script is working, but process ctrl+c to exit
// doesn't work w/o this interface creation
require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
// stop process input
process.stdin.pause();
// read from stdin 10 times per second to check if ctrl+c pressed
@ghalusa
ghalusa / youtube_id_regex.php
Created June 20, 2015 23:14
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class