Skip to content

Instantly share code, notes, and snippets.

@llagerlof
llagerlof / side-by-side-phabriactor-wiki-editor.css
Created August 19, 2021 19:30 — forked from benvium/side-by-side-phabriactor-wiki-editor.css
Userstyle for Phabricator Wiki to enable Side-by-side editing, and to hide loads of unused stuff.Use Patterns: https://*/phriction/edit/*
/* SIDE BY SIDE PHRICTION EDIT */
/* add a userstyle with pattern */
/* L H S */
/* pos of left-hand editor */
.phui-box.phui-box-border.mlt.mll.mlr.phui-object-box.phui-object-box-lightblue {
margin-right: 800px !important;
margin-left:0 !important;
@llagerlof
llagerlof / FFmpeg | Basic Operation on Subtitles.md
Created August 13, 2021 01:39 — forked from innat/FFmpeg | Basic Operation on Subtitles.md
Remove hard subtitles from video file || Integrate subtitles into a video file || Generate .srt file from a video file.

Download FFmpeg for Windows

Steps

  • Download FFmpeg
  • Extract it and save it to C drive ( choose any location - it's optional )
  • Set environment variable - copy the location of bin folder which is inside the extracted file and set the location on system path variable.
  • Done!
@llagerlof
llagerlof / index.html
Created November 19, 2020 12:00 — forked from kahole/index.html
*scratch*.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>*scratch*</title>
<style>
body {
font-family: Hack, Menlo, Monaco, 'Droid Sans Mono', 'Courier New', monospace;
white-space: pre;
@llagerlof
llagerlof / automorphic.php
Created September 18, 2020 16:00
PHP Automorphic Number Finder Algorithm
<?php
/*
PHP Automorphic Number Finder Algorithm
Author: Lawrence Lagerlof
License: MIT
*/
$limit = 1000000;
$milestone = $limit / 100;
for ($n = 2; $n <= $limit; $n++) {
$square = (string) $n * $n;
@llagerlof
llagerlof / embedded-file-viewer.md
Created July 22, 2020 19:52 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@llagerlof
llagerlof / print_r_reverse.php
Last active May 28, 2024 03:19
Convert the output string of print_r to array again.
<?php
// original author: https://www.php.net/manual/en/function.print-r.php#93529
// another dev said it was fixed for null values, but I don't encountered errors with null values for Matt's: https://www.php.net/manual/en/function.print-r.php#121259
// Matt
function print_r_reverse($in) {
$lines = explode("\n", trim($in));
if (trim($lines[0]) != 'Array') {
// bottomed out to something that isn't an array
return $in;
@llagerlof
llagerlof / enable_mysql_query_log.sh
Created March 4, 2020 15:07
Start logging all queries executed by MySQL server
# Must run as root in mysql cli
SET global log_output = 'FILE';
SET global general_log_file='mysql_sql.log';
SET global general_log = 1;
# Disable with SET global general_log = 0;
git tag -am "annotation goes here" tagname_goes_here # cut a tag
git tag -d tagname_goes_here # burn it
git tag -am "annotation goes here" tagname_goes_here # cut another tag
git push --tags # push tags to remote
git push origin :refs/tags/tagname_goes_here # delete tag from remote
@llagerlof
llagerlof / substring_exists.js
Last active October 29, 2019 18:15
Return true if string is inside another string, locale independent.
function substringExists(haystack, needle)
{
size_haystack = haystack.length;
size_needle = needle.length;
loop = size_haystack - size_needle;
for (i=0; i < loop + 1; i++) {
sub = haystack.substr(i, size_needle);
c = sub.localeCompare(needle, {}, {sensitivity: 'base'});
if (c === 0) {
return true;
@llagerlof
llagerlof / id_date_valid.php
Created August 12, 2019 19:00
One liner to identify a valid datetime "Y-m-d H:i:s" on PHP
<?php
/*
This script can be used on terminal. Eg:
$ php id_date_valid.php 2019-08-12 15:23:58
*/
$datetime = $argv[1] . ' ' . $argv[2];
if ($datetime == date('Y-m-d H:i:s', strtotime ($datetime))) {
echo "true";
} else {