Skip to content

Instantly share code, notes, and snippets.

View chyanju's full-sized avatar
🤔

Yanju Chen chyanju

🤔
View GitHub Profile
@chyanju
chyanju / fetch.py
Last active April 20, 2024 10:21
Returning basic machine specs via http
import urllib.request
import json
import argparse
import ipaddress
from tabulate import tabulate
ap = argparse.ArgumentParser()
ap.add_argument(
"-t", "--timeout", default=0.1, type=float, help="timeout, default: 0.1"
)
@chyanju
chyanju / ExprASN.py
Created May 21, 2021 16:57
ExprASN@210521
from asn.grammar.dsl_ast import AbstractSyntaxTree
from typing import List
from torch import tensor
import torch
import torch.nn as nn
import torch.nn.functional as F
import random
from asn.components.dataset import ExprBatch, Example
from asn.grammar.transition_system import ApplyRuleAction, GenTokenAction, ActionTree
from asn.grammar.hypothesis import Hypothesis
@chyanju
chyanju / example1_invalid.smv
Last active June 24, 2020 17:31
Temporal Model Checking Examples using TLV
-- simple finite state machine construction for temporal properties checking
-- properties checking:
-- "Where processing is based on consent, the controller shall be able to demonstrate that the data subject has consented to processing of his or her personal data."
-- run the following proof command in TLV (https://cs.nyu.edu/acsys/tlv/)
-- mc ltl( [] ( user_consent Awaits !data_access ) );
-- this yields an invalid result
MODULE main
VAR
-- whether user has given the consent to access the data
@chyanju
chyanju / dSplitFast.jl
Created January 18, 2016 02:23
Distributed Splitting Function, Splitting M into N pieces
"Distributed Splitting Function, Splitting M into N pieces"
function dSplitFast(M,N)
a = [floor(Int64,M/N)+(i<=M%N) for i=1:N]
b = unshift!([sum(a[1:j]) for j=1:N],0)
c = [p[1]+1:p[2] for p in[b[k:k+1] for k=1:N]]
return c
end
@chyanju
chyanju / pMXNet_1.jl
Last active June 24, 2020 10:04
A Piece of Code from MXNet.jl
"Utility macro to call MXNet API functions"
macro mxcall(fv, argtypes, args...)
f = eval(fv)
args = map(esc, args)
quote
_mxret = ccall( ($(Meta.quot(f)), $MXNET_LIB),
Cint, $argtypes, $(args...) )
if _mxret != 0
err_msg = mx_get_last_error()
throw(MXError(err_msg))
@chyanju
chyanju / gMul.jl
Created January 15, 2016 10:41
A Demo of Matrix Multiplication on A GPU, Using MXNet Lower-Level API
# A Demo of Matrix Multiplication on Multiple GPUs
using MXNet
"Delete & Release NDArray Memory - Good Status"
macro del(arr)
quote
mx.@mxcall(:MXNDArrayFree,(mx.MX_handle,),$(esc(arr)).handle.value)
mx.@mxcall(:MXNDArrayWaitAll,())
$(esc(arr)).handle.value = C_NULL