Skip to content

Instantly share code, notes, and snippets.

View lawliet89's full-sized avatar
🧑‍🤝‍🧑
He/him

Yong Wen Chua lawliet89

🧑‍🤝‍🧑
He/him
  • Singapore
  • 08:10 (UTC +08:00)
View GitHub Profile
@lawliet89
lawliet89 / gist:9677319
Created March 21, 2014 00:54
OpenCL Inline PTX for 256 Bits unsigned addition & multiplication
// Credits: http://goo.gl/NtaADC
// Inline PTX assembly
uint add_asm(uint *result, const uint *a, const uint *b) {
uint carry;
asm("{\n\t"
"add.cc.u32 %0, %9, %17; \n\t"
"addc.cc.u32 %1, %10, %18; \n\t"
"addc.cc.u32 %2, %11, %19; \n\t"
"addc.cc.u32 %3, %12, %20; \n\t"
@lawliet89
lawliet89 / WebBrowserExtensions.cs
Last active October 12, 2022 13:06
Calling Javascript Object Method in a System.Windows.Forms.WebBrowser Contorl
using System;
using System.Linq;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace AsynchronousWebPage
{
/// <summary>
/// Extension convenience methods to invoke arbitrary Javascript method on a web page
/// hosted by a WebBrowser control.
@lawliet89
lawliet89 / terraform-pre-apply
Created September 11, 2022 00:50
TFC Workload Identity for AWS Hooks
#!/bin/bash
set -euo pipefail
if [ -z ${TFC_AWS_APPLY_ROLE_ARN+x} ] && [ -z ${TFC_AWS_RUN_ROLE_ARN+x} ]; then
echo "Skipping this script because both env vars are missing and unset";
else
set +u
ROLE_ARN="${TFC_AWS_APPLY_ROLE_ARN:-$TFC_AWS_RUN_ROLE_ARN}"
set -u
echo "Preparing AWS provider auth..."
@lawliet89
lawliet89 / prime.cpp
Created November 12, 2012 23:24
Prime Numbers (SPOJ)
// https://www.spoj.pl/problems/PRIME1/
//http://www.swageroo.com/wordpress/spoj-problem-2-prime-generator-prime1/
#include <iostream>
using namespace std;
int main(){
int count;
cin >> count;
while(count--){
@lawliet89
lawliet89 / vault-token-helper.rb
Created May 28, 2021 08:05
Vault Token Helper
#!/usr/bin/env ruby
require 'json'
require 'date'
unless ENV['VAULT_ADDR']
STDERR.puts "No VAULT_ADDR environment variable set. Set it and run me again!"
exit 100
end
@lawliet89
lawliet89 / SuperStack.cs
Created February 16, 2015 13:07
HackerRank Super Stack Solution
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Solution
{
class Solution
{
static void Main(string[] args)
@lawliet89
lawliet89 / gist:5899943
Created July 1, 2013 10:55
Git grep for trailing whitespace
git grep -I -E '^.+[ ]+$'
@lawliet89
lawliet89 / gcrgc.sh
Last active November 23, 2020 08:57 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@lawliet89
lawliet89 / Dockerfile
Last active July 25, 2020 06:22
Yarn Example Test Code for #1750
FROM node:7.1
# Install yarn
RUN set -x \
&& curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get install yarn
WORKDIR /src/app
@lawliet89
lawliet89 / binary-search-tree.cpp
Last active June 3, 2020 03:48
C++ Generic Binary Search Tree
#include <iostream>
#include <new>
#include <cassert>
#define NUMBER 9
template <typename T> class Node {
public:
Node<T> *parent, *left, *right;