Skip to content

Instantly share code, notes, and snippets.

View v9n's full-sized avatar
🛫
forward email at mailwip.com

Vinh Quốc Nguyễn v9n

🛫
forward email at mailwip.com
View GitHub Profile
@v9n
v9n / WireGuard_Setup.txt
Created March 16, 2024 22:12 — forked from chrisswanda/WireGuard_Setup.txt
Stupid simple setting up WireGuard - Server and multiple peers
Install WireGuard via whatever package manager you use. For me, I use apt.
$ sudo add-apt-repository ppa:wireguard/wireguard
$ sudo apt-get update
$ sudo apt-get install wireguard
MacOS
$ brew install wireguard-tools
Generate key your key pairs. The key pairs are just that, key pairs. They can be
@v9n
v9n / tree.ps1
Last active January 27, 2023 21:04
tree.ps1
#Variables that need to be set for each run
$startFolder = $args[0];
$destinationHTMLFile = "c:\\tree.html"; #The final html file that will be produced, #does not need to exist
$htmlLines = @();
#Function that creates a folder detail record
function CreateFolderDetailRecord
{
param([string]$FolderPath)
@v9n
v9n / binary.rb
Created January 1, 2023 03:01 — forked from xfbs/binary.rb
Ruby: convert string to binary form and back (one liners
# not the most efficient way,
# but you get the idea.
str = "meow"
# convert string to binary
bin = str.bytes.map{|d| d.to_s(2)}.map{|b| b.rjust(8, '0')}.join
puts bin
# and convert it back to a string
Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As LongPtr, ByVal y As LongPtr) As LongPtr
Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As LongPtr, ByVal dx As LongPtr, ByVal dy As LongPtr, ByVal cButtons As LongPtr, ByVal dwExtraInfo As LongPtr)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As LongPtr = &H8
Public Const MOUSEEVENTF_RIGHTUP As LongPtr = &H10
Sub DoNotSleepPlease()
Dim i As Integer
This file has been truncated, but you can view the full file.
# Title: StevenBlack/hosts with the fakenews and gambling extensions
#
# This hosts file is a merged collection of hosts from reputable sources,
# with a dash of crowd sourcing via GitHub
#
# Date: 10 June 2022 03:10:21 (UTC)
# Extensions added to this file: fakenews, gambling
# Number of unique domains: 114,621
#
# Fetch the latest version of this file: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts
@v9n
v9n / sendmail
Created March 28, 2014 02:05
Sending Email with mail
The Linux command line can be very powerful once you know how to use it. You can parse data, monitor processes, and do a lot of other useful and cool things using it. There often comes a need to generate a report and mail it out. It could be as simple a requirement as a notification that the day’s backup went through fine, or did not. I’ll help you get started with sending mails from the Linux command line and in shell scripts. We will also cover sending attachments from the command line. We will begin with the “mail” command.
MAIL
First run a quick test to make sure the “sendmail” application is installed and working correctly. Execute the following command, replacing “you@youremailid.com” with your e-mail address.
# mail -s “Hello world” you@youremailid.com
Hit the return key and you will come to a new line. Enter the text “This is a test from my server”. Follow up the text by hitting the return key again. Then hit the key combination of Control+D to continue. The command prompt will ask you if you want
@v9n
v9n / esbuild.js
Created October 14, 2021 17:59
Esbuild with devserber and scss
const esbuild = require('esbuild');
const sassPlugin = require('esbuild-plugin-sass')
const http = require('http');
let publicURL = "/"
let nodeEnv = "development"
const buildOptions = {
entryPoints: ['src/index.jsx'],
bundle: true,
@v9n
v9n / gist:4323171
Created December 17, 2012 22:52
Check free space on IOS device
//@author http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device
- (uint64_t)freeDiskspace
{
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;
__autoreleasing NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
@v9n
v9n / Gemfile
Created April 21, 2021 06:11 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@v9n
v9n / index.js
Created April 11, 2021 00:29
hanami webhook demo
const express = require('express');
const app = express();
const port = 4443;
app.use(express.json()); //Used to parse JSON bodies
// HANAMI added this
app.use(express.urlencoded({extended:false})); //Parse URL-encoded bodies
app.get('/', (req, res) => {