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
[ | |
// Vim navigation | |
// | |
{ | |
"key": "ctrl+h", | |
"command": "workbench.action.focusLeftGroup", | |
"when": "editorTextFocus && vim.active && vim.mode != 'Insert' && !firstEditorInGroup" | |
}, | |
{ | |
"key": "ctrl+l", |
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
//****************************************************************************** | |
// | |
// Timer.cpp | |
// | |
// Copyright (c) 2016 Brandon To | |
// This code snippet is licensed under the BSD 3-clause license. | |
// | |
// Author: Brandon To | |
// Created: August 24, 2016 | |
// |
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
#include <pthread.h> | |
#include <sched.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/syscall.h> | |
#include <iostream> | |
#include <bitset> |
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
#define _WINSOCK_DEPRECATED_NO_WARNINGS | |
#include <iostream> | |
#include <winsock2.h> | |
#include <Windows.h> | |
#include <stdint.h> | |
#include <Ws2tcpip.h> | |
#pragma comment(lib, "wsock32.lib") | |
#pragma comment(lib, "Ws2_32.lib") |
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
#define _WINSOCK_DEPRECATED_NO_WARNINGS | |
#include <iostream> | |
#include <winsock2.h> | |
#include <Windows.h> | |
#include <stdint.h> | |
#include <Ws2tcpip.h> | |
#pragma comment(lib, "wsock32.lib") | |
#pragma comment(lib, "Ws2_32.lib") |
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
// Socket used for receiving packets | |
DatagramSocket receiveSocket = new DatagramSocket(Constants.SERVER_PORT); | |
// Socket will time out after 1 second | |
receiveSocket.setSoTimeout(1000); | |
try | |
{ | |
// Creates and start loop to quit on input q | |
Thread quitThread = new Thread( |
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
// For Tianming | |
// Encodes an int as 2 bytes | |
public class TestByteIntConversion | |
{ | |
public static void main(String[] args) | |
{ | |
int blockNumber = 257; | |
System.out.println("Block number = " + blockNumber); |
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
wget -np -r --reject "index.html*" http://www.webpagetodownload.com/path/to/folder |
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
/// x: 8-bit value. k: bit position to set, range is 0-7. b: set bit to this, either 1 or 0 | |
unsigned char SetBit(unsigned char x, unsigned char k, unsigned char b) { | |
return (b ? (x | (0x01 << k)) : (x & ~(0x01 << k)) ); | |
// Set bit to 1 Set bit to 0 | |
} | |
unsigned char GetBit(unsigned char x, unsigned char k) { | |
return ((x & (0x01 << k)) != 0); | |
} |
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
#include <stdio.h> | |
void initialize_array(int arr[], int val); | |
int main() | |
{ | |
int arr[30]; | |
initialize_array(arr, 5); |