Skip to content

Instantly share code, notes, and snippets.

View jsyeo's full-sized avatar
💭
💍 𝔁𝓾𝓮🥶𝓱𝓾𝓪:female_fairy:𝓹𝓲𝓪𝓸😻𝓹𝓲𝓪𝓸👣

Jason Yeo jsyeo

💭
💍 𝔁𝓾𝓮🥶𝓱𝓾𝓪:female_fairy:𝓹𝓲𝓪𝓸😻𝓹𝓲𝓪𝓸👣
View GitHub Profile
@jsyeo
jsyeo / install_dist_pip.bat
Last active February 15, 2022 05:10
Batch file to create virtualenv, download and install distribute + pip on Windows 7 machines (Python 3.3)
cd %USERPROFILE%
REM create the venv
C:\Python33\python.exe C:\Python33\Tools\Scripts\pyvenv.py %USERPROFILE%\venv
REM download get-pip.py and distribute_setup.py
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py','%USERPROFILE%\get-pip.py')
@jsyeo
jsyeo / power_now.py
Created July 20, 2012 07:28
Python Script To Print Current Laptop Battery Power
#!/usr/bin/python
def main():
power_now = open("/sys/class/power_supply/BAT0/energy_now", "r").readline()
power_full = open("/sys/class/power_supply/BAT0/energy_full", "r").readline()
print float(power_now)/float(power_full) * 100 , "%"
if __name__ == "__main__":
main()
@jsyeo
jsyeo / README.md
Last active February 28, 2021 18:32 — forked from jmb/README.md

Description

This is a fork of jmb's awesome widget that grabs the events with a private address instead of going through the tiresome process of Google's OAuth authentication.

Dashing widget to display the next and some subsequent Google Calendar events using the Google Calendar's private urls.

See the screenshot below

Installation

@jsyeo
jsyeo / .ideavimrc
Created January 21, 2021 04:31
IDEA vimrc
set ignorecase
set smartcase
set scrolloff=8
" Integrate with system clipboard
set clipboard=unnamedplus,unnamed
let mapleader = " "
nmap <leader>p :action ParameterInfo<CR>
@jsyeo
jsyeo / Gadt.sc
Created January 19, 2021 08:01
Scala 3 GADTs
object Main {
enum Expr[+T] {
case MyInt(i: Int) extends Expr[Int]
case Bool(b: Boolean) extends Expr[Boolean]
case Add(x: Expr[Int], b: Expr[Int]) extends Expr[Int]
case Eq(x: Expr[T], b: Expr[T]) extends Expr[Boolean]
}
import Expr._
@jsyeo
jsyeo / config.fish
Last active January 12, 2021 06:05
My fish config
# ~/.config/fish/config.fish
# git/hub
abbr git hub
abbr gst 'hub status'
abbr gd 'hub diff'
abbr ga 'hub add'
abbr gc 'hub commit'
abbr gp 'hub push'
abbr gpb 'hub push -u origin (hub rev-parse --abbrev-ref HEAD)'
@jsyeo
jsyeo / parse.rb
Last active December 23, 2020 03:10
JRuby AST from string
def parse s
sc = org.jruby.runtime.scope.ManyVarsDynamicScope.new(JRuby.runtime.getStaticScopeFactory().newLocalScope(nil, 'file'), nil)
is = java.io.ByteArrayInputStream.new(java.lang.String.new(s).get_bytes(java.nio.charset.StandardCharsets::UTF_8))
JRuby.runtime.parseFileFromMain is, 'file', sc
end
node = parse '1+3' #=> #<Java::OrgJrubyAst::RootNode:0x70f822e>
node.child_nodes.get(0)
/*
* Copyright 2011 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
@jsyeo
jsyeo / Main.java
Created September 9, 2015 06:31
Reflection with Method Param
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Main {
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
// write your code here
Class a = A.class;
Method m = a.getMethod("vulnerableMethod", int.class);
m.invoke(null, 5);
@jsyeo
jsyeo / Cargo.toml
Created May 15, 2015 08:59
Calling rust from ruby ffi
[package]
name = "double"
version = "0.1.0"
authors = ["Jason Yeo <jasonyeo88@gmail.com>"]
[lib]
name = "double"
crate-type = ["dylib"]