This file contains hidden or 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
//libusb+ch340 data transfer demo | |
//gcc usb.c `pkg-config libusb-1.0 --libs --cflags` -o usb | |
#include <errno.h> | |
#include <signal.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <sys/select.h> |
This file contains hidden or 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
# https://stackoverflow.com/questions/28908319/how-to-clear-an-ipython-notebooks-output-in-all-cells-from-the-linux-terminal | |
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --clear-output *.ipynb |
This file contains hidden or 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
// source: https://stackoverflow.com/questions/57113226/how-to-prevent-google-colab-from-disconnecting | |
// author: Tanay Karve | |
function ConnectButton(){ | |
console.log("Connect pushed"); | |
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click() | |
} | |
setInterval(ConnectButton,60000); |
This file contains hidden or 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
xinput --set-prop $MOUSE_ID "Coordinate Transformation Matrix" 0.1 0 0 0 0.1 0 0 0 1 |
This file contains hidden or 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 subprocess | |
# grab subnet address | |
ps = subprocess.Popen('ifconfig', stdout=subprocess.PIPE, shell=True) | |
output = subprocess.check_output(('grep', 'inet'), stdin=ps.stdout) | |
ps.wait() | |
elements = output.decode('utf8').split() | |
broadcast_ip = elements[elements.index('broadcast') + 1] | |
print('broadcast_ip: {}'.format(broadcast_ip)) | |
subnet = broadcast_ip[:-4] |
This file contains hidden or 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 random | |
import time | |
class Simulation(): | |
def __init__(self): | |
self.sigma = 2; | |
self.score = random.randint(1, 100) | |
print('### network score', self.score) | |
def simulate(self): |
This file contains hidden or 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 contractExists(address adrs) internal returns (bool) { | |
uint length; | |
assembly { | |
length := extcodesize(adrs) | |
} | |
if (length > 0) { | |
return true; | |
} else { | |
return false; | |
} |
This file contains hidden or 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
pragma solidity ^0.4.11; | |
import "./Token.sol"; | |
contract Settlement { | |
bytes32 public permutationID; | |
address public tokenA; | |
address public tokenB; | |
mapping(address => mapping(bytes32 => uint)) public orders; |
This file contains hidden or 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
contract Exchange { | |
struct Bid { | |
address owner; | |
uint price; | |
uint amount; | |
uint date; | |
} | |
struct Ask { |
This file contains hidden or 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 submitBid(uint _price, uint _amount) bidInMarket(_price) external returns (bool) { | |
Bid memory b; | |
b.price = _price; | |
b.amount = _amount; | |
for(uint i = 0; i < Bids.length; i++) { | |
if(Bids[i].price > _price) { | |
Bid[] memory tempBids = new Bid[](Bids.length - i); | |
for(uint j = i; j < Bids.length; j++) { | |
tempBids[j-i] = Bids[j]; | |
} |
NewerOlder