Skip to content

Instantly share code, notes, and snippets.

View dangkhoasdc's full-sized avatar
😎

Le Tan Dang Khoa dangkhoasdc

😎
View GitHub Profile
@dangkhoasdc
dangkhoasdc / ArchLinuxWSL2.md
Last active March 18, 2024 02:21 — forked from ld100/ArchLinuxWSL2.md
Steps for setting up Arch Linux on WSL2

Upgrading to WSL 2

  • Download WSL2 Kernel
  • run wsl --set-default-version 2 in windows command line, so that all future WSL machine will use WSL2.

Installing Arch Linux

Basic installation

@dangkhoasdc
dangkhoasdc / DisablingBitcodeiOS.cs
Last active March 20, 2023 03:29
Automatically disabling bitcode for iOS build on Unity
// Place this script in Assets > Editor
public class DisablingBitcodeiOS
{
[PostProcessBuild( 1000 )]
public static void PostProcessBuildAttribute( BuildTarget target, string pathToBuildProject )
{
if(target == BuildTarget.iOS)
{
string projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
@dangkhoasdc
dangkhoasdc / fixed_queue.h
Created February 13, 2023 01:51
C++ Create fixed size queue
// credit: https://stackoverflow.com/a/56334648
#include <queue>
#include <deque>
#include <iostream>
template <typename T, int MaxLen, typename Container=std::deque<T>>
class FixedQueue : public std::queue<T, Container> {
public:
void push(const T& value) {
if (this->size() == MaxLen) {
@dangkhoasdc
dangkhoasdc / .ctags
Created February 26, 2019 07:35 — forked from romainl/.ctags
My ctags config
--langmap=javascript:.js.es6.es.jsx
--javascript-kinds=-c-f-m-p-v
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\2/A,Array,Arrays/
--regex-javascript=/^[ \t]*(var|let|const)[ \t]+([A-Z][A-Za-z0-9_$]+)[ \t]*=[ \t]*function/\2/C,Class,Classes/
--regex-javascript=/^[ \t]*class[ \t]+([A-Za-z0-9_$]+)/\1/C,Class,Classes/
--regex-javascript=/^[ \t]*export[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\3/E,Export,Exports/
--regex-javascript=/^[ \t]*export[ \t]?({[ \t]*)*([A-Za-z0-9_\*]*[ \t]as[ \t])*([A-Za-z0-9_]+),[ \t]*([A-Za-z0-9_\*]*[ \t]as[ \t])([A-Za-z0-9_]+)/\5/E,export,Exports/
struct random_access_iterator {
using difference_type = std::ptrdiff_t;
using value_type = ?;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::random_access_iterator_tag;
random_access_iterator();
random_access_iterator(const random_access_iterator& rhs);
random_access_iterator(random_access_iterator&& rhs);
@dangkhoasdc
dangkhoasdc / cuda_set_limit.cu
Created October 22, 2018 10:30
cudaDeviceSetLimit example
#include <cudnn.h>
#include <cuda.h>
#include <iostream>
#include <chrono>
#include <thread>
int main(int argc, char const *argv[]) {
// cuda initialization via cudaMalloc
size_t limit = 0;
//Example 2. Application Using C and CUBLAS: 0-based indexing
//-----------------------------------------------------------
// to compile: nvcc filename.cpp -lcublas -std=c++11
#include <iostream>
#include <chrono>
#include <thread>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
/* This program uses the host CURAND API to generate 100
* pseudorandom floats.
*
* Code taken verbatim from CURAND library documentation.
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <curand.h>
@dangkhoasdc
dangkhoasdc / setup_ubuntu.md
Last active June 4, 2018 07:40
Ubuntu Setup for Machine Learning

Ubuntu

  1. Install Dropbox

LogMeIn

  1. Create an account on LogMeIn.
  2. Install the client Hamachi
  3. Log in and join the network
@dangkhoasdc
dangkhoasdc / optimizers.py
Created May 4, 2018 05:54 — forked from kastnerkyle/optimizers.py
Theano optimizers
# Authors: Kyle Kastner
# License: BSD 3-clause
import theano.tensor as T
import numpy as np
import theano
class rmsprop(object):
"""
RMSProp with nesterov momentum and gradient rescaling