Skip to content

Instantly share code, notes, and snippets.

View phanmn's full-sized avatar

phanmn

  • Ho Chi Minh city, Viet Nam
View GitHub Profile
@phanmn
phanmn / how-to-add-route-OpenVPN.md
Created June 13, 2017 01:43
Adding route on client using OpenVPN
@phanmn
phanmn / sipTcpTransport.js
Last active November 11, 2024 00:00
SIP.js TCP Transport Implementation
const SIP = require('sip.js');
const net = require('net');
const TransportStatus = {
STATUS_CONNECTING: 'STATUS_CONNECTING',
STATUS_CONNECTED: 'STATUS_CONNECTED',
STATUS_CLOSING: 'STATUS_CLOSING',
STATUS_CLOSED: 'STATUS_CLOSED'
};
@phanmn
phanmn / ripple.styl
Created May 1, 2019 06:10
Vue Ripple Directive
.ripple
position relative
overflow hidden
transform translate3d(0, 0, 0)
.ripple:after
content ''
display block
position absolute
width 100%
@phanmn
phanmn / machine.js
Last active March 7, 2021 17:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@phanmn
phanmn / MarqueeText.vue
Created April 18, 2021 05:21
vue3-marquee-text-component
<script lang="ts">
import { defineComponent, h, useCssModule } from 'vue';
// https://github.com/EvodiaAut/vue-marquee-text-component/blob/master/src/components/MarqueeText.vue
export default defineComponent({
name: 'MarqueeText',
props: {
duration: {
type: Number,
default: 15,
@phanmn
phanmn / index.html
Created June 24, 2021 07:23
Electron Capture App Screen
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<video id="video" autoplay playsinline></video>
@phanmn
phanmn / main.rs
Created April 12, 2024 08:20
Rust Simple Http Server
use std::io::{Read, Write};
use std::net::TcpListener;
fn main() -> std::io::Result<()> {
let listener = TcpListener::bind("127.0.0.1:9000")?;
println!("Listening on port 9000");
for conn in listener.incoming() {
let mut conn = conn?;
@phanmn
phanmn / snowflake-id.sql
Created July 31, 2024 10:26 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@phanmn
phanmn / phone_number.ex
Created August 19, 2024 04:14
Absinthe Graphql Schema Scalar Phone Number
defmodule AppWeb.Graphql.Schema.Types.Custom.PhoneNumber do
@moduledoc """
The phone number scalar type.
"""
use Absinthe.Schema.Notation
require Logger
require OK
scalar :phone_number, name: "PhoneNumber", open_ended: true do
description("""