Skip to content

Instantly share code, notes, and snippets.

View yuikns's full-sized avatar

Yu yuikns

View GitHub Profile
// Copyright [2015] <Yu Jing>
#include <cstdio>
#include <string>
#include <map>
using std::string;
using std::map;
char ch_searcher(const std::string & s) {
class Solution {
public:
void reverse(string &w) {
unsigned int len = w.length();
for(unsigned int i = 0 ; i < len / 2 ; i ++ ) {
char t = w[i];
w[i] = w[len - 1 - i];
w[len - 1 - i] = t;
}
}
@yuikns
yuikns / pac.cc
Created February 12, 2015 01:46
Producer And Consumer
#include <cstdio>
#include <cstring>
#include <pthread.h> // thread
#include <unistd.h> // usleep
#include <string>
#include <mutex> // std::lock_guard , mutex
#include <queue> // queue
val json = net.liftweb.json.JsonParser.parse("[{\"foo\":1,\"bar\":2},{\"foo\":3,\"bar\":4}]")
implicit val formats = net.liftweb.json.DefaultFormats
case class Info(foo:Int,bar:Int)
val m = json.extract[List[Info]]
m.foreach{x=> println(x.foo+"|"+x.bar)}
@yuikns
yuikns / IP17MON.cpp
Last active August 29, 2015 14:18 — forked from ZRJ/IP17MON.cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#include <fstream>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
// usage : g++ thread_pool.cc -o tp -pthread --std=c++11
// remove chrono header and timer, you may modify this file to c
// usage : gcc xxx.c -o tp_in_c -pthread --std=c99
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <pthread.h>
#include <unistd.h>
#include <chrono> // for timer
package com.argcv.util.mongo;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;
<?xml version="1.0" encoding="UTF-8"?>
<rexster>
<http>
<server-port>8182</server-port>
<server-host>0.0.0.0</server-host>
<base-uri>http://127.0.0.1</base-uri>
<web-root>public</web-root>
<character-set>UTF-8</character-set>
<enable-jmx>false</enable-jmx>
<enable-doghouse>true</enable-doghouse>
object Solution {
def main(args: Array[String]): Unit = {
val n = Console.in.readLine().toInt
val sl = (1 to n).map(i => (Console.in.readLine(),i))
//io.Source.stdin.getLines().take(1).map(_.toInt)
println(math.abs(sl.par.foldLeft(0){(l,e) =>
val i = e._2 - 1
val arr = e._1.split(" ")
l + arr(i).toInt - arr(n - i - 1).toInt
package org.aminer.io.utils
import scala.util.Try
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import com.google.common.cache.LoadingCache
//import com.google.common.cache.CacheBuilder
//import com.google.common.cache.CacheLoader