Skip to content

Instantly share code, notes, and snippets.

View kevinjanada's full-sized avatar

Kevin Janada kevinjanada

  • Jakarta, Indonesia
View GitHub Profile
@allenhark
allenhark / snippets.js
Created June 7, 2021 18:17 — forked from beautyfree/snippets.js
Solana Web3 Snippets
import * as web3 from '@solana/web3.js';
// Create connection
function createConnection(url = "https://testnet.solana.com") {
return new web3.Connection(url);
}
const connection = createConnection();
// Generate account
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@amanjuman
amanjuman / Sendy Nginx Config
Last active February 26, 2024 20:04
Sendy Nginx Config for PHP8.1 FPM
sudo su
//Setup Hostname
hostnamectl set-hostname subdomain.domain.tld
## Basic
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get autoremove -y && sudo apt-get install software-properties-common
//Setup SWAP
sudo fallocate -l 1G /swapfile;
ls -lh /swapfile;
@alfonsomunozpomer
alfonsomunozpomer / Fetch.test.js
Created September 28, 2017 12:51
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
@tomasbasham
tomasbasham / install_tmux_osx_no_brew
Last active April 29, 2024 08:46 — forked from Fi5t/install_tmux_osx_no_brew
Install tmux on OSX WITHOUT brew
# Create a directory
mkdir ~/tmux-install
cd ~/tmux-install
# Get the files
curl -OL https://www.openssl.org/source/openssl-1.0.2l.tar.gz
curl -OL https://github.com/tmux/tmux/releases/download/2.3/tmux-2.3.tar.gz
curl -OL https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
# Extract them
@aviskase
aviskase / bash_colors.sh
Last active February 14, 2024 01:43
Custom bash prompt. Sets git branch (colored) and virtualenv
# Reset
Reset='\[\e[0m\]' # Text Reset
# Common colors
Black='\[\e[0;30m\]' # Black
Red='\[\e[0;31m\]' # Red
Green='\[\e[0;32m\]' # Green
Yellow='\[\e[0;33m\]' # Yellow
Blue='\[\e[0;34m\]' # Blue
Purple='\[\e[0;35m\]' # Purple
@kelleyk
kelleyk / compton.conf
Last active September 19, 2023 12:36
# This is my compton configuration after a quick cleanup. (It's still none too organized; sorry about that.)
# With this file at ~/.config/compton.conf, I can run compton without any arguments (just plain `compton`).
#
# In the hopes that explaining my software and hardware environment might be helpful to you:
#
# I use this configuration on Ubuntu 15.10 (and have used it on previous releases); I am currently using the 352.63 ("long-lived
# branch") NVIDIA binary drivers, installed from the Ubuntu software repositories. I use fluxbox as my window manager; most of
# the other components of my desktop environment are borrowed from Xfce.
#
# My workstation at home has an i7-4930K and a GTX 970 in it, which are together more than enough to drive several 4K displays