Skip to content

Instantly share code, notes, and snippets.

View stevenroh's full-sized avatar
🇨🇭

Steven Roh stevenroh

🇨🇭
View GitHub Profile
@stevenroh
stevenroh / Auth.js
Created September 29, 2022 20:39 — forked from chadmuro/Auth.js
Supabase Auth Context
import React, { useContext, useState, useEffect, createContext } from 'react';
import { supabase } from '../supabase';
// create a context for authentication
const AuthContext = createContext();
export const AuthProvider = ({ children }) => {
// create state values for user data and loading
const [user, setUser] = useState();
const [loading, setLoading] = useState(true);
# Combines several solutions found on the internet
class ImplicitFTP_TLS(ftplib.FTP_TLS):
"""FTP_TLS subclass to support implicit FTPS."""
"""Constructor takes a boolean parameter ignore_PASV_host whether o ignore the hostname"""
"""in the PASV response, and use the hostname from the session instead"""
def __init__(self, *args, **kwargs):
self.ignore_PASV_host = kwargs.get('ignore_PASV_host') == True
super().__init__(*args, {k: v for k, v in kwargs.items() if not k == 'ignore_PASV_host'})
self._sock = None
<?php
/* Template Name: Test */
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
@stevenroh
stevenroh / axios-catch-error.js
Created January 28, 2019 10:02 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@stevenroh
stevenroh / parallax-no.css
Created November 1, 2018 09:58 — forked from marisqaporter/parallax-no.css
disable parallax effect on parallax pro theme by genesis
/* Disable Parallex effect on Home Sections 1, 2, and 3
--------------------------------------------- */
.home-section-1, .home-section-3, .home-section-5 {
background-attachment: scroll;
background-color: #fff;
background-position: 50% 0px;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
@stevenroh
stevenroh / random.md
Created October 26, 2018 19:45 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@stevenroh
stevenroh / clear.txt
Created March 28, 2018 08:12 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache
@stevenroh
stevenroh / pll_copy_post_metas.php
Created December 20, 2017 08:37 — forked from qstudio/pll_copy_post_metas.php
WP / PolyLang / Un-Sync Specified Custom Fields
<?php
// filter to exclude specified post_meta from Polylang Sync ##
add_filter( 'pll_copy_post_metas', 'q_pll_copy_post_metas' );
/**
* Remove defined custom fields from Polylang Sync
*
* @since 0.1
* @param Array $metas
@stevenroh
stevenroh / DisableGWX.mkd
Last active September 16, 2015 11:47 — forked from maciakl/DisableGWX.mkd
Disable Windows 10 Free Upgrade Reservation Prompt in Windows 7

Disable GWX Windows 10 Upgrade Prompt

There is no user friendly way disable the annoying task bar icon that prompts you to "reserve" a free upgrade to Windows 10. You can however get rid of it by adding a registry key under:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\GWX

The key you are adding should be a DWORD named DisableGWX and it's vale should be set to 1.