Skip to content

Instantly share code, notes, and snippets.

@aidev13
aidev13 / flask.md
Created November 29, 2023 00:24
Setting up a Flask server for Python

Setting up a Flask server for Python - for Windows

Editor used is VsCode and MUST use powershell for command line

Step 1: Create a Virtual Environment - In the root directory/folder (I choose to use the word folder), run the following command

python -m venv venv

The venv folder should appear.

Quick start

Tauri is shipped with state management function/feature by default.

Basic usage is quite simple: a variable of State type can be accessed on the tauri commands which you have defined; in other words, "with tauri commands, they'll magically inject state for you," so that once a variable is managed you can inject them directly as additional input when defining the command.

Example Implementation

@marcoandre1
marcoandre1 / SSH-configuration-github-gitlab.md
Last active July 16, 2024 06:44
Managing SSH keys for Github and Gitlab

Managing SSH keys for Github and Gitlab

NOTICE: This guide will help you set ssh keys for GitHub and GitLab. However, this is not going to change your commit user.name or user.email. If you need to change those for specific repositories, just run the following commands while in your repository:

git config user.name "Your Name Here"
git config user.email your@email.com

For more info, see this answer. Also, keep in mind this only changes the .git folder inside your repository which never gets added/committed/pushed/uploaded.

I recently had to manage two ssh keys (one for Github and one for Gitlab). I did some research to find the best solution. I am justing putting the pieces together here.

@ityonemo
ityonemo / test.md
Last active July 19, 2024 06:53
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@barbogast
barbogast / schemaTypes.ts
Created May 18, 2020 15:00
Typescript Definitions for Sanity schemas
import { ReactElement } from 'react'
import { ReactComponentLike } from 'prop-types'
type Meta = {
parent: { [key: string]: any }
path: string[]
document: { [key: string]: any }
}
type CustomRuleCallback = (field: any, meta: Meta) => true | string | Promise<true | string>
@ianldgs
ianldgs / dayjs-zoned.d.ts
Last active October 6, 2022 09:21
DayJS Zoned
import { Dayjs, PluginFunc, ConfigType } from 'dayjs';
declare const plugin: PluginFunc;
export = plugin;
declare module 'dayjs' {
/** Similar to date-fns/utcToZonedTime */
function utcToZoned(config: ConfigType, timezone?: string): Dayjs;
/** Similar to date-fns/zonedTimeToUtc */
@tripflex
tripflex / functions.php
Last active August 13, 2023 18:16
Programmatically create a WooCommerce Subscription and associated WooCommerce Order
<?php
public function give_user_subscription( $product, $user_id, $note = '' ){
// First make sure all required functions and classes exist
if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){
return false;
}
$order = wc_create_order( array( 'customer_id' => $user_id ) );
@necojackarc
necojackarc / Set up Vim with clipboard on Ubuntu on WSL2.md
Last active December 28, 2023 02:45
Set up Vim on Ubuntu on Windows Subsystem for Linux 2 (WSL2) to share clipboard

This explains how to set up Vim on Ubuntu 18.04 on Windows Subsystem for Linux 2 (WSL2) in order to share the clipboard between Windows and Ubuntu.

Environments

  • Windows 10 Home
  • Ubuntu 18.04 on Windows Subsystem for Linux 2 (WSL2)

Steps

  1. Build Vim with the clipboard option enabled
  2. Set up VcXsrv Windows X Server
@temsool
temsool / acf-date.text
Created October 8, 2019 10:20
ACF Pro Datapicker min max date limit
function.php
------------------
function my_acf_admin_enqueue_scripts() {
// register style
wp_register_style( 'my-acf-input-css', get_stylesheet_directory_uri() . '/css/my-acf-input.css', false, '1.0.0' );
wp_enqueue_style( 'my-acf-input-css' );
// register script
@jeffposnick
jeffposnick / service-worker.js
Created September 20, 2019 00:56
Example of InjectManifest in Workbox v5
// Add any other logic here as needed.
import { CacheableResponsePlugin } from 'workbox-cacheable-response/CacheableResponsePlugin';
import { CacheFirst } from 'workbox-strategies/CacheFirst';
import { createHandlerForURL } from 'workbox-precaching/createHandlerForURL';
import { ExpirationPlugin } from 'workbox-expiration/ExpirationPlugin';
import { NavigationRoute } from 'workbox-routing/NavigationRoute';
import { precacheAndRoute } from 'workbox-precaching/precacheAndRoute';
import { registerRoute } from 'workbox-routing/registerRoute';