Skip to content

Instantly share code, notes, and snippets.

View yongkangc's full-sized avatar
🎃
Focusing

Chia Yong Kang yongkangc

🎃
Focusing
View GitHub Profile
@0xdeployer
0xdeployer / frameIndex.ts
Last active February 9, 2024 05:00
Nethria Text Based Mini Game Frame
import { Request, Response } from "express";
import { createCanvas } from "canvas";
import GifEncoder from "gifencoder";
export async function generateImage(label: string): Promise<Buffer> {
const width = 955;
const height = 500;
const canvas = createCanvas(width, height);
const ctx = canvas.getContext("2d");
@Markkop
Markkop / SimpleRewards.sol
Created April 15, 2022 02:16
A staking contract using a loop to save rewards data for each staker
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./RewardToken.sol";
contract StakingManager is Ownable{
@alyleite
alyleite / wsl.md
Last active July 10, 2024 19:19
Failed to connect to bus: Host is down - WSL 2

» sudo systemctl daemon-reload

System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

==============================================

Edit*

  1. Open /etc/wsl.conf with any editor:
@letiesperon
letiesperon / Rails credentials
Last active January 18, 2024 21:08
What I need to know about Rails 6 credentials and master key
The credentials are stored in the "credentials.yml.enc" file, encrypted.
To decrypt the credentials file, you need a master key that is set on either:
* config/master.key file (for local development)
* ENV["RAILS_MASTER_KEY"] (for deployed environments)
What should you commit?
* The file config/master.key should be ignored in gitignore (you should not commit the master key)
* The file credentials.yml.enc should be commited along with the codebase (but don't worry, only those who have the master key can decrypt it)
@azrafe7
azrafe7 / heroku_pydrive_gdrive_upload2folder.md
Created April 25, 2020 21:42
NOTES: heroku + pydrive + GDrive auth + upload to folder
  • setup heroku project
  • setup GDrive auth via cloud console (watch out for slashes when setting up URIs)
  • download client_secrets.json and put it in the local root folder (so PyDrive can use it)
  • gitignore it
  • use CommandLineAuth() instead of LocalWebserverAuth() locally
  • put the relevant secrets in local json files to be used for auth locally
  • test it locally and ensure it all works
  • create secret env keys in heroku with the content of both received jsons
  • be sure to gitignore both json files
  • create a ".profile" that will create the two files from ENV secrets when the docker image is run on heroku
/*///////////////////
CSS
Build a simple product visualiser with Gravity Forms Color Picker
Full article at https://jetsloth.com/labs/build-a-simple-product-visualiser-with-gravity-forms-color-picker/
////////////////////*/
/* Outter form wrapper */
.gform_body {
background:#f6f6f6;
border-radius:10px;
@elrayle
elrayle / byebug_commands.md
Last active June 11, 2024 22:03
Byebug Cheatsheet - organized by related commands

Byebug Cheatsheet

This cheatsheet includes most of the byebug commands organized by related commands (e.g. breakpoint related commands are together).

To see official help...

Command Aliases Example Comments
help h h list top level of all commands
help cmd h cmd-alias h n list the details of a command (example shows requesting details for the next command) (this works for all commands)

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings
#Resume Phrase Matcher code
#importing all required libraries
import PyPDF2
import os
from os import listdir
from os.path import isfile, join
from io import StringIO
@bradtraversy
bradtraversy / pipenv_cheat_sheet.md
Last active July 7, 2024 20:34
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell