Skip to content

Instantly share code, notes, and snippets.

@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@bradtraversy
bradtraversy / vscode_shortcuts.md
Last active May 13, 2024 14:12
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

@Salies
Salies / exif.py
Last active March 1, 2022 10:14
Image comment edition with piexif (example)
import piexif
def set_desc(imgPath, message):
exif_dict = piexif.load(imgPath)
exif_dict['0th'][40092] = string_to_array(message)
exif_bytes = piexif.dump(exif_dict)
piexif.insert(exif_bytes, imgPath)
return 1
def string_to_array(string):
@faiyazalam
faiyazalam / instagram.php
Created January 3, 2017 17:46
Get recent images from Instagram using PHP & cURL
<?php
/**
* Supply a user id and an access token
* Jelled explains how to obtain a user id and access token in the link provided
* @link http://jelled.com/instagram/access-token
*/
$userid = "";
$accessToken = "";
// Get our data
function fetchData($url){
@guillaumevincent
guillaumevincent / README.md
Last active April 28, 2024 00:51
Windows Service with Python 3.5 and pyinstaller
@xPaw
xPaw / steam_quick_queue.user.js
Last active May 19, 2024 05:16
⚠ This script has been integrated into SteamDB browser extension!
// ==UserScript==
// @name Steam Queue Auto Discoverer
// @description Discover the Steam queue three times to get the sale cards
// @version 2.3.0
// @namespace https://gist.github.com/xPaw/73f8ae2031b4e528abf7
// @icon https://store.steampowered.com/favicon.ico
// @match https://store.steampowered.com/explore*
// @grant none
// ==/UserScript==
@paulcollett
paulcollett / functions.php
Last active December 19, 2023 04:42
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php...
// Remove All Yoast HTML Comments
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423)
add_filter( 'wpseo_debug_markers', '__return_false' );
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php...
@tomvon
tomvon / resize-image-keep-aspect-ratio.py
Created June 8, 2014 22:59
Python script to resize an image while keeping the original aspect ratio.
#Resizes an image and keeps aspect ratio. Set mywidth to the desired with in pixels.
import PIL
from PIL import Image
mywidth = 300
img = Image.open('someimage.jpg')
wpercent = (mywidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
@wokamoto
wokamoto / user_meta_transient.php
Last active July 17, 2023 11:53
[WordPress] user_meta transient
<?php
/**
* Delete a user meta transient.
*/
function delete_user_meta_transient( $user_id, $transient ) {
global $_wp_using_ext_object_cache;
$user_id = (int) $user_id;
do_action( 'delete_user_meta_transient_' . $transient, $user_id, $transient );
@willurd
willurd / web-servers.md
Last active May 23, 2024 20:20
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000