Skip to content

Instantly share code, notes, and snippets.

View HatScripts's full-sized avatar
🎩

HatScripts HatScripts

🎩
View GitHub Profile
@HatScripts
HatScripts / run_as_admin.py
Last active September 18, 2020 15:41 — forked from GaryLee/RunAsAdmin.py
Elevate the privilege to admin. Support both python script and pyinstaller wrapped program. Need ctypes only.
# Based on Gary Lee's code:
# https://gist.github.com/GaryLee/d1cf2089c3a515691919
# https://stackoverflow.com/a/33856172/2203482
def run_as_admin(argv=None):
import ctypes
shell32 = ctypes.windll.shell32
if argv is None and shell32.IsUserAnAdmin():
return True
import sys
@HatScripts
HatScripts / codepen_jokes.md
Last active December 18, 2023 00:10
Programming jokes/one-liners found on CodePen
  • A Pen is worth a thousand docs.
  • Be the developer your linter thinks you are.
  • How do you comfort a JavaScript bug? You console it!
  • How would you React if I said I love Vue?
  • If a groundhog inspects their Web Component, do they see their Shadow DOM?
  • If you get tired, be like an AJAX request and REST.
  • If you want to flex your skills and go off the grid, try coding a layout with float.
  • Keep friends close and formatters closer.
  • Keep the <main> thing the <main> thing.
  • Knock knock! Race condition. Who's there?
@HatScripts
HatScripts / array.js
Last active February 3, 2024 08:13
JavaScript helper snippets
// Find first value matching a condition
arr.find(e => someCondition(e))
// e.g.
[12, 5, 8, 130, 44].find(i => i > 100) // 130
[7, 3, 9, 5, 6, 1].find(i => i % 2 == 0) // 6
// Remove FIRST occurrence of value from array
let index = arr.indexOf(value)
if (index > -1) {
arr.splice(index, 1)
*{
box-shadow: none !important;
transition: none !important;
-webkit-transition: none !important;
-moz-transition: none !important;
-o-transition: none !important;
}
@media /* Large screen, non-retina */
only screen and (min-width: 1000px) {
@HatScripts
HatScripts / video-thumbnails-generator.sh
Created August 24, 2018 05:26 — forked from shunchu/video-thumbnails-generator.sh
Batch generate thumbnails from mp4 files using ffmpg
#!/bin/bash
# setup
FILES=name_of_file_to_match_*.mp4
SEEK_POINT=00:00:30
IMG_FORMAT=png
FRAME_SIZE=150X100
DEST=thumbnails
for f in $FILES
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Running: with_example
80% (8 of 10) |##################### | Elapsed Time: 0:00:00 ETA: 0:00:00
Running: with_example_stdout_redirection
100% (10 of 10) |#########################| Elapsed Time: 0:00:01 Time: 0:00:01
70% (7 of 10) |################## | Elapsed Time: 0:00:00 ETA: 0:00:00 80% (8 of 10) |##################### | Elapsed Time: 0:00:00 ETA: 0:00:00 90% (9 of 10) |######################## | Elapsed Time: 0:00:00 ETA: 0:00:00
100% (10 of 10) |#########################| Elapsed Time: 0:00:01 Time: 0:00:01
Running: basic_widget_example
100%|#########################################################################|
Test: N/A% |/ | ETA: --:--:-- 0.0 s/BTest: 100% || | Time: 0:00:00 1.9 MiB/s
1.7 MiB/s <<<|########################################|>>> 100% Time: 0:00:00
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function xdiff_string_diff(oldData, newData, contextLines) {
// discuss at: http://locutus.io/php/xdiff_string_diff
// original by: Brett Zamir (http://brett-zamir.me)
// based on: Imgen Tata (http://www.myipdf.com/)
// bugfixed by: Imgen Tata (http://www.myipdf.com/)
// improved by: Brett Zamir (http://brett-zamir.me)
// note 1: The minimal argument is not currently supported
// example 1: xdiff_string_diff('', 'Hello world!')
// returns 1: '@@ -0,0 +1,1 @@\n+Hello world!'
// (This code was done by Imgen Tata; I have only reformatted for use in Locutus)