Skip to content

Instantly share code, notes, and snippets.

@jecyhw
jecyhw / plupload_picture_preview.js
Last active December 25, 2016 14:04
plupload的图片预览
//图片预览
function previewPicture(file) {
var img = new moxie.image.Image();
img.onload = function () {
$preview.attr('id', this.uid).addClass('thumbnail').html('');
this.bind('embedded', function () {
$preview.children().css({
width: '100%',
height: 'auto'
});
@jecyhw
jecyhw / spring_boot_csrf.js
Last active December 22, 2016 07:05
spring boot ajax request with csrf
// <meta name="_csrf" th:content="${_csrf.token}"/>
// <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
$(function () {
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
});
@jecyhw
jecyhw / Concatenated_Words.java
Last active March 14, 2017 01:40
LeetCode Weekly Contest 13字典树
public class Solution {
class Node {
Node[] next = new Node[26];
boolean end = false;
void add(String s) {
Node cur = this;
for (int i = 0;i < s.length(); ++i) {
int ind = s.charAt(i) - 'a';
if (cur.next[ind] == null) {
@jecyhw
jecyhw / Total_Hamming_Distance.cpp
Created December 18, 2016 03:16
LeetCode Weekly Contest 13
class Solution {
public:
struct node {
int z, o;
node() {
z = o = 0;
}
};
@jecyhw
jecyhw / Leetcode_474_Ones_and_Zeroes.cpp
Created December 12, 2016 00:50
LeetCode Weekly Contest 12
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
struct node {
int z, o;
node() {}