This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method was deprecated in API level 28 | |
// https://developer.android.com/reference/android/net/NetworkInfo | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
final ConnectivityManager connMgr = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE); | |
final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | |
final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); | |
if (wifi.isConnectedOrConnecting()) { | |
output.setText("Network Type: WIFI"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img id="test" /> | |
<script> | |
let mock_console = { | |
log: function(...args) { console.log(...args); } | |
}; | |
let mock_document = { | |
getElementById: function(element_name) { return window.document.getElementById(element_name); }, | |
createElement: function(element_name) { return null; }, // restricted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(n, computers): | |
network = [0 for _ in range(n)] | |
done = False | |
no = 0 | |
for idx in range(n): | |
if network[idx] == 0: | |
no += 1 | |
current = no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encode_query_string(x) { | |
let output = []; | |
Object.keys(x).forEach(function(key) { | |
output.push(`${encodeURIComponent(key)}=${encodeURIComponent(x[key])}`); | |
}); | |
return output.join('&'); | |
} | |
function decode_query_string(x) { | |
let output = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
import java.util.Random; | |
public class Queue<T> implements QueueInterface<T>, Iterable<T> { | |
private static final int DEFAULT_CAPACITY = 10; | |
private int current = 0; | |
private int rear = 0; | |
private Object[] queueArray = null; | |
private int capacity = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get strace-4.21.tar.xz from https://sourceforge.net/projects/strace/files/strace/4.21/ | |
tar -xJf strace-4.21.tar.xz | |
cd strace-4.21 | |
export STAGING_DIR=/home/user/source/staging_dir | |
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-mipsel_24kc_gcc-7.3.0_musl | |
export LDCFLAGS=$TOOLCHAIN_DIR/usr/lib | |
export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/usr/lib | |
export PATH=$TOOLCHAIN_DIR/bin:$PATH | |
export CC=$TOOLCHAIN_DIR/bin/mipsel-openwrt-linux-gcc | |
export AS=$TOOLCHAIN_DIR/bin/mipsel-openwrt-linux-as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socketserver import BaseRequestHandler, TCPServer | |
from socket import socket, AF_INET, SOCK_STREAM | |
from threading import Thread | |
BIND_HOST, BIND_PORT = "0.0.0.0", 22 | |
HOST, PORT = "192.168.100.5", 22 | |
def relay(fromSock, toSock): | |
while True: | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name KAIST PMS Blocker | |
// @namespace http://0xF.kr/ | |
// @version 0.1 | |
// @description Automatically closes PMS page | |
// @author JiminP | |
// @match http://143.248.113.1/CPopupRequest | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inner closures | |
function create(i) { | |
return function () { | |
console.log(i); | |
}; | |
} | |
for (var i = 0; i < 1; i++) { | |
setTimeout(create(i), 100); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BaseHTTPServer, SimpleHTTPServer | |
PORT = 8080 | |
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.end_headers() | |
self.wfile.write(b'<h1 style="text-align: center">UNDER CONSTRUCTION</h1>') |