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 is the background code... | |
// listen for our browerAction to be clicked | |
chrome.browserAction.onClicked.addListener(function (tab) { | |
// for the current tab, inject the "inject.js" file & execute it | |
chrome.tabs.executeScript(tab.ib, { | |
file: 'inject.js' | |
}); | |
}); |
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
/** | |
*Submitted for verification at Etherscan.io on 2018-06-12 | |
*/ | |
pragma solidity ^0.4.13; | |
library SafeMath { | |
/** | |
* @dev Multiplies two numbers, throws on overflow. |
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 UIKit | |
private var INSColorPickerWindow: UIWindow? | |
class INSColorPickerView: UIViewController { | |
private var screenshotForCollectionViewAsImage: UIImage? | |
private var completion: ((UIColor) -> Void)? | |
private let penView = UIView() |
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
extension UIView { | |
func getColourFromPoint(point:CGPoint) -> UIColor { | |
let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB() | |
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue) | |
var pixelData:[UInt8] = [0, 0, 0, 0] | |
let context = CGContext(data: &pixelData, width: 1, height: 1, bitsPerComponent: 8, bytesPerRow: 4, space: colorSpace, bitmapInfo: bitmapInfo.rawValue) | |
context?.translateBy(x: -point.x, y: -point.y) | |
if let _context = context { |
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
extension UICollectionView { | |
// Snapshot of UICollectionView, wherever you scroll, it captures the visible cells on screen as an image | |
func snapshot() -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(self.frame.size, false, 0) | |
UIGraphicsBeginImageContext(bounds.size) | |
self.drawHierarchy(in: frame, afterScreenUpdates: true) | |
let screenshot = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return screenshot |
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
$wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.bz2 | |
$tar xvf protobuf-2.5.0.tar.bz2 | |
$cd protobuf-2.5.0 | |
$./configure CC=clang CXX=clang++ CXXFLAGS='-std=c++11 -stdlib=libc++ -O3 -g' LDFLAGS='-stdlib=libc++' LIBS="-lc++ -lc++abi" | |
$make -j 4 | |
$sudo make install | |
$protoc --version |
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
/** | |
* Doc: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket | |
* */ | |
'use strict'; | |
// 通信协议定义 | |
class YLGroupChatProtocol { | |
constructor () { | |
this.create_room = 1001; | |
this.send_content = 1002; |
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
// Notification Messages | |
// This is made by Publish-Subscribe Topics | |
class YLNotificationMessages { | |
constructor () { | |
// Event Objects: storing event name and event callback | |
this.events = {}; | |
} | |
// Subscribe Event |
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 tornado.ioloop | |
import tornado.web | |
import os | |
from tornado.options import define, options | |
define("port", default=8100, help="run on the given port", type=int) | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): |
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
// https://stackoverflow.com/questions/21731044/is-there-a-way-to-attach-an-event-handler-to-the-list-of-running-processes-in-c | |
// | |
static void Main(string[] args) | |
{ | |
var query = new EventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa \"Win32_Process\""); | |
using (var eventWatcher = new ManagementEventWatcher(query)) | |
{ | |
eventWatcher.EventArrived += eventWatcher_EventArrived; | |
eventWatcher.Start(); |
NewerOlder