Skip to content

Instantly share code, notes, and snippets.

View jerrydeng's full-sized avatar

Jerry Deng jerrydeng

View GitHub Profile
document.onpaste = function (event) {
// use event.originalEvent.clipboard for newer chrome versions
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
// find pasted image among pasted items
var blob = null;
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") === 0) {
blob = items[i].getAsFile();
}
@jerrydeng
jerrydeng / scrape-google-image-search.py
Created July 20, 2017 15:46 — forked from kekeblom/scrape-google-image-search.py
A script for scraping image thumbnails from google image search using selenium.
# Copyright (c) 2016 Kenneth Blomqvist
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
@jerrydeng
jerrydeng / gist:5515445
Created May 4, 2013 00:43
HTTMultiParty to upload attachment with oauth2
class SomeClass
include HTTMultiParty
def self.upload(update, picture, token)
response = post(post_url,
:query => {
:status => update,
:pic => File.new(file_path),
:access_token => token
})
15:08:27,605 INFO [org.jboss.modules] JBoss Modules version 1.1.2.GA
15:08:27,937 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
15:08:27,991 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.x.incremental.1 "Steropes" starting
15:08:27,998 DEBUG [org.jboss.as.config] Configured system properties:
[Standalone] =
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
@jerrydeng
jerrydeng / gist:3184456
Created July 26, 2012 20:56
mod_cluster config
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so
LoadModule manager_module modules/mod_manager.so
<Location /mod_cluster_manager>
SetHandler mod_cluster-manager
AllowDisplay On
</Location>
@jerrydeng
jerrydeng / gist:3183945
Created July 26, 2012 19:19
Bundler Error
rails _3.1.6_ new sample2
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
<subsystem xmlns="urn:jboss:domain:modcluster:1.0">
<mod-cluster-config advertise-socket="modcluster" proxy-list="domain.name" excluded-contexts="invoker,jbossws,juddi,console">
<dynamic-load-provider>
<load-metric type="busyness"/>
</dynamic-load-provider>
</mod-cluster-config>
</subsystem>
@jerrydeng
jerrydeng / gist:3172736
Created July 24, 2012 21:21
domain.name
Listen domain.name:6666
<VirtualHost domain.name:6666>
ServerName domain.name
<Directory />
Order deny,allow
Deny from all
Allow from all
</Directory>
CreateBalancers 1
<IfModule manager_module>
Listen 127.0.0.1:6666
ManagerBalancerName torquebox-balancer
<VirtualHost 127.0.0.1:6666>
KeepAliveTimeout 300
MaxKeepAliveRequests 0
#AdvertiseFrequency 5
@jerrydeng
jerrydeng / README.md
Created May 19, 2012 13:46 — forked from aiwilliams/README.md
Storyboard in RubyMotion 1.4

Start XCode and create a new Storyboard file. I closed all my other XCode projects. When you choose the location of the created file, it should be your RubyMotion project's resources directory. Add a UIViewController, and set it's identifier property to "Start". Add some UI elements so you can see it working.

When you run rake in your RubyMotion project, it will compile the .storyboard file. You could auto-load the Storyboard using a plist configuration, but you'll see code can do it too.