Skip to content

Instantly share code, notes, and snippets.

Avatar
😸
use code::latest ;

GAURAV gauravssnl

😸
use code::latest ;
View GitHub Profile
@gauravssnl
gauravssnl / loc.md
Created Oct 25, 2021 — forked from MaskRay/loc.md
Very coarse estimate of compiler complexity/LOC
View loc.md

It is by no means accurate and is comparing apples and oranges in many dimensions, e.g.

  • Targeting LLVM IR, C, assembly have varying difficulty.
  • Some may include runtime while some may not.
  • Different compilers are written in different languages. Languages have different expressiveness. Different paradigms have varying expressiveness.
  • LLVM has many non-default passes which are not used by regular compilation. I try to use fine-grained directories but still some unneeded files are included.

Nevertheless, here is the result (auxiliary files like shell/Makefile/documentation are ignored):

  • gcc (2207000+): tokei gcc libcpp -e ada -e d -e go -e objc -e objcp -e '*test*'
@gauravssnl
gauravssnl / servewasm.py
Created Oct 20, 2021 — forked from prideout/servewasm.py
Python WASM server
View servewasm.py
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map.update({
'.wasm': 'application/wasm',
View ExceptionTranslation.java
// Exception translation
public
class ExceptionTranslation {
public
String readTheFile(String f) {
try
(BufferedReader is = new BufferedReader(new FileReader(f))) {
String line = is.readLine();
return line;
}
View adbd_launch.sh
db shell am start -n "com.gauravssnl.wifiadb/com.gauravssnl.wifiadb.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
@gauravssnl
gauravssnl / adbwificonnect.sh
Created Sep 4, 2021 — forked from amanshuraikwar/adbwificonnect.sh
Shell script to connect a USB connected device via adb over WiFi
View adbwificonnect.sh
# Purpose: Shell script to connect a USB connected device via adb over WiFi
#
# Author: Amanshu Raikwar
#
# Assumptions:
# 1. USB debugging is enabled in the Android device
# 2. The Android device is connected to the computer via USB
# 3. The Android device is connected to the same wifi as the computer
# 4. The Android device is accessible through port 5555 over the wifi network
#
View restart.py
#!/usr/bin/env python
# Waits for the parent process to terminate, then executes specified commands.
import os
import signal
import sys
import syslog
import time
@gauravssnl
gauravssnl / update-golang.md
Created Sep 4, 2021 — forked from nikhita/update-golang.md
How to update the Go version
View update-golang.md

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

View ElementPath-xpath_tokenizer-original.py
def xpath_tokenizer(pattern, namespaces=None):
for token in xpath_tokenizer_re.findall(pattern):
tag = token[1]
if tag and tag[0] != "{" and ":" in tag:
try:
prefix, uri = tag.split(":", 1)
if not namespaces:
raise KeyError
yield token[0], "{%s}%s" % (namespaces[prefix], uri)
except KeyError:
@gauravssnl
gauravssnl / README.md
Created Sep 2, 2021 — forked from goodmami/README.md
Parsing JSON with regular expressions
View README.md

Parsing JSON with Regular Expressions

When I learned of regular expression engines that support recursion I thought I could write a recursive-descent parser in regex. Since I've written JSON parsers a few times and it's a simple spec, I chose that as the test case. In the end I created two versions.

version 1

@gauravssnl
gauravssnl / quotes.py
Created Sep 2, 2021 — forked from goodmami/quotes.py
List of unicode quote symbols
View quotes.py
# quote list: https://en.wikipedia.org/wiki/Quotation_mark
QUOTES = (
'\u0022' # quotation mark (")
'\u0027' # apostrophe (')
'\u00ab' # left-pointing double-angle quotation mark
'\u00bb' # right-pointing double-angle quotation mark
'\u2018' # left single quotation mark
'\u2019' # right single quotation mark
'\u201a' # single low-9 quotation mark
'\u201b' # single high-reversed-9 quotation mark