Skip to content

Instantly share code, notes, and snippets.

View phuonghuynh's full-sized avatar
🐷
lazy

phuong phuonghuynh

🐷
lazy
View GitHub Profile
@phuonghuynh
phuonghuynh / 00_README.md
Created February 24, 2024 07:39 — forked from LeZuse/00_README.md
Install node on Apple Silicon M1 both ARM and x86 (Rosetta)

Node.js on Apple Silicon

Node Version Manager (https://github.com/nvm-sh/nvm) works perfectly across native node installations as well as emulated Rosetta installations. The trick I am using here is to install one LTS version of node under Rosetta and another stable version as native binary.

TODO

  • find a way how to run the same node version on both platforms
@phuonghuynh
phuonghuynh / gist:cfefa53250bf322b793f217aca9d157f
Created February 22, 2024 17:01
Powershell script to create iso file from a folder
function Write-IStreamToFile([__ComObject] $istream, [string] $fileName)
{
# NOTE: We cannot use [System.Runtime.InteropServices.ComTypes.IStream],
# since PowerShell apparently cannot convert an IStream COM object to this
# Powershell type. (See http://stackoverflow.com/a/9037299/223837 for
# details.)
# It turns out that .NET/CLR _can_ do this conversion.
#
# That is the reason why method FileUtil.WriteIStreamToFile(), below,
# takes an object, and casts it to an IStream, instead of directly
require 'net/http'
require 'uri'
require 'json'
require 'net/http'
@job_name = ENV['JOB_NAME']
@build_number = ENV['BUILD_NUMBER']
@jenkins_url = ENV['JENKINS_URL']
@phuonghuynh
phuonghuynh / AuthenticationToken.java
Last active March 7, 2023 11:17
Spring Security - Multiple Authentication Providers
public class AuthenticationToken extends AbstractAuthenticationToken {
private String token;
public AuthenticationToken(String token) {
super(null);
this.token = token;
setAuthenticated(false);
}
@phuonghuynh
phuonghuynh / select2.js
Created January 13, 2015 06:22
Useful configuration for Select2 component
$(".searchText").select2({
width: "100%",
tags: tags, // => tagging support, allow use add new entry
tokenSeparators: [" "], // => to separate entries
formatSelection: instance.function (item) {
if (item.id === item.text) {
return "<div style='height: 16px;'>" + item.text + "</div>";
}
return "<img style='width: 16px; height: 16px;' src='images/" + item.logo + "'> " + item.text + " </img>";
}, // => "on select" : useful to handle "unidentified" entry (should return new tag)
@phuonghuynh
phuonghuynh / nginx.conf
Created January 9, 2015 03:22
Nginx Configuration support Web Socket handshake
http {
...
server {
...
location /ws {
proxy_pass http://127.0.0.1:8080/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
@phuonghuynh
phuonghuynh / HttpSessionInitializer.java
Last active August 29, 2015 14:13
Spring Security 4x support Web Socket
public class HttpSessionInitializer extends AbstractHttpSessionApplicationInitializer {
protected String getDispatcherWebApplicationContextSuffix() {
return AbstractDispatcherServletInitializer.DEFAULT_SERVLET_NAME;
}
}
@phuonghuynh
phuonghuynh / README.md
Last active October 21, 2019 08:38
D3 Bubble chart
@phuonghuynh
phuonghuynh / WebConfig.java
Created November 21, 2014 06:46
Default welcome file without web.xml
public class WebConfig extends WebMvcConfigurerAdapter {
@Resource
private Environment environment;
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
public void addViewControllers(ViewControllerRegistry registry) {