Skip to content

Instantly share code, notes, and snippets.

View jswhisperer's full-sized avatar
🕵️
For Sale... I mean open to work.

Gregory The JSWhisperer jswhisperer

🕵️
For Sale... I mean open to work.
View GitHub Profile
@jswhisperer
jswhisperer / safeJsonParse.ts
Created November 2, 2023 20:10
safeJsonParse
const safeJsonParse = <T>(str: string) => {
try {
const jsonValue: T = JSON.parse(str);
return jsonValue;
} catch {
return undefined;
}
};
@mvidaldp
mvidaldp / sdcard_fix.md
Created April 11, 2022 12:43
SD card formating fix via ADB shell when Android GUI fails (internal, portable/external or mixed). Works on Retroid Pocket 2+

I wrote this short tutorial because extending my internal storage using my new micro SD card on my Retroid Pocket 2+ failed all the time. Only setting it up as portable/external worked. However, this instructions should work in any Android 5.0+ device.

So, in case you have problems setting up your SD card on your Android device via graphical interface (setting up storage as extended internal memory or portable), and you get a corrupted SD card or any other error, follow these steps to fix it via adb shell:

  1. Make sure you have adb access to your Android device: Settings > System > About, touch/click on Build number until Developer options are enabled:
  2. Go to Settings > System > Developer options and enable USB debugging.
  3. Assuming you have adb installed on your remote terminal run the following:

adb shell

@citruz
citruz / QEMU_ON_M1.md
Last active January 25, 2025 10:23
Create Ubuntu and Windows VMs with QEMU on Apple Silicon

Running Linux and Windows on M1 with QEMU

30.11.2020: Updated with the new patchseries and instructions for Windows

02.12.2020: Added tweaks

08.12.2020: Updated with patchseries v4

31.01.2020: Updated with patchseries v6

@gdjohn4s
gdjohn4s / desktop-shortcut.md
Last active January 5, 2023 22:35
Create Ubuntu Desktop shortcut

How to create Desktop shortcut on ubuntu 18.04

To create a desktop shortcut on your ubuntu, just open gedit on desktop and paste those strings:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/snap/bin/skype
# DOCKERFILE
FROM ubuntu:latest
ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
ENV FFMPEG_VERSION=3.0.2
WORKDIR /tmp/ffmpeg
RUN apt-get -y update && apt-get -y dist-upgrade && apt-get -y install software-properties-common
RUN add-apt-repository ppa:mc3man/trusty-media -y
RUN apt-get -y install ffmpeg
@wgminer
wgminer / wcag-contrast-ratio.js
Last active February 12, 2025 00:20
A simple JavaScript function that takes two hex color values and calculates their contrast ratio (according to the WCAG 2.0 guidelines).
var contrast = function (foreground, background) {
var hexToRgb = function (hex) {
// Expand shorthand form (e.g. '03F') to full form (e.g. '0033FF')
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
@adactio
adactio / basicServiceWorker.js
Last active March 27, 2023 09:30
A basic Service Worker, for use on, say, a blog.
'use strict';
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function() {
// Update 'version' if you need to refresh the cache
var staticCacheName = 'static';
var version = 'v1::';

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@milanaryal
milanaryal / schema-org-structured-data-markup-using-microdata.html
Last active February 14, 2025 23:15
An example of how to mark up a HTML5 webpage using the schema.org schemas and microdata.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Site Title</title>
<link rel="stylesheet" href="/assets/css/style.min.css">
@jswhisperer
jswhisperer / verticalalign.css
Created January 14, 2014 17:26
Vertical align with CSS
.element {
position: relative;
top: 50%;
transform: translateY(-50%);
}