Skip to content

Instantly share code, notes, and snippets.

@wihoho
wihoho / addWord.js
Created January 9, 2017 07:22
Import words into youdao
function addWord(word){
console.log(word);
$.ajax({
type: 'GET',
url: 'http://dict.youdao.com/wordbook/ajax',
dataType: 'json',
data:{action:'addword',q:word,date:new Date(),le:'eng'},
// beforeSend: ajaxBeforeFn,
success: function(data){
@wihoho
wihoho / Controller.java
Created October 10, 2016 07:50
Upload file using Javascript
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public void upload(@RequestParam("file") MultipartFile file) {
String rawFile = file.getContentType();
System.out.println();
}
@wihoho
wihoho / js_copy.js
Created May 21, 2015 08:28
Js copy
wap.core.ui.hueDrive.ShareDialog.prototype.executeCopy = function (text) {
var input = document.createElement('textarea');
document.body.appendChild(input);
input.value = text;
input.focus();
input.select();
document.execCommand('Copy');
input.remove();
};
@wihoho
wihoho / extractJapanese.java
Created January 6, 2015 15:43
extract japanese from files using regular expression
package co.jp.worksap;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpression {
public static void main( String args[] ) throws FileNotFoundException {
@wihoho
wihoho / java
Created November 18, 2014 16:32
admin template
import org.primefaces.component.datatable.DataTable;
import org.primefaces.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import java.util.HashMap;
import java.util.Map;
@wihoho
wihoho / AdminManager.java
Last active August 29, 2015 14:07
SQL insert, update, retrieve
package com.lynda.javatraining.db.tables;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.lynda.javatraining.db.DBType;
import com.lynda.javatraining.db.DBUtil;
@wihoho
wihoho / imageCompress.py
Created May 27, 2014 06:28
python module to compress an image
import os
from PIL import Image
directory = "3 photos"
i = 0
for file in os.listdir(directory):
if file == ".DS_Store":
continue
fullName = directory +"/"+ file
@wihoho
wihoho / 1.cpp
Created December 1, 2013 08:55
第3周 字符串 作业题
#include <iostream>
using namespace std;
void getResult(char str[]){
int numbers[26];
for(int j = 0; j < 26; j ++)
numbers[j] = 0;
@wihoho
wihoho / 1.cpp
Created December 1, 2013 08:50
数据结构与算法 / 第2周 栈与队列 作业题
#include <iostream>
using namespace std;
struct PocketCard {
char x;
int y;
};