This file contains hidden or 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
private static int[] BASE_CHARS; | |
static { | |
BASE_CHARS = new int[26]; | |
int a_idx = (int)'a'; | |
for (int i=0; i<26; i++) { | |
BASE_CHARS[i] = a_idx + i; | |
} | |
} |
This file contains hidden or 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
var nums = new Array(); | |
for (var i=0;i<10;i++){ | |
nums.push(i); | |
} | |
var outputs = [0,0,0,0]; | |
for (var j=0;j<4;j++){ | |
var idx = (Math.random() * nums.length) | 0; | |
outputs[j] = nums[idx]; | |
nums.splice(idx,1); | |
} |
This file contains hidden or 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
void merge(int[] arr, int start, int mid, int end, int[] tmp) { | |
int i = 0; | |
int j = 0; | |
int k = 0; | |
while (i <= mid && j <= end) { | |
if (arr[i] < arr[j]) { | |
tmp[k++] = arr[i++]; | |
} else { | |
tmp[k++] = arr[j++]; | |
} |
This file contains hidden or 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
// insert | |
void minHeapUp(int[] arr, int i) { | |
int j = (i - 1) / 2; // parent index | |
int tmp = arr[i]; | |
while (j >= 0 && i != 0) { | |
if (arr[j] <= arr[i]) { | |
break; | |
} | |
arr[i] = arr[j]; | |
i = j; |
This file contains hidden or 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
#!/bin/bash | |
# Install parallel on CentOS 6. | |
# Assumes you are root. Prefix w/ sudo if not. | |
cd /etc/yum.repos.d/ | |
#wget http://download.opensuse.org/repositories/home:tange/CentOS_CentOS-5/home:tange.repo | |
wget http://download.opensuse.org/repositories/home:/tange/CentOS_CentOS-6/home:tange.repo | |
yum install parallel |
This file contains hidden or 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
package controllers | |
import java.util.Properties | |
import com.typesafe.config.ConfigFactory | |
import kafka.consumer.{Consumer, ConsumerConfig, ConsumerConnector, Whitelist} | |
import kafka.serializer.StringDecoder | |
import play.api.libs.iteratee.{Enumerator, Iteratee} | |
import play.api.mvc.{Controller, WebSocket} |
This file contains hidden or 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
package { | |
import flash.errors.IOError; | |
import flash.events.ErrorEvent; | |
import flash.events.Event; | |
import flash.events.IOErrorEvent; | |
import flash.events.ProgressEvent; | |
import flash.events.SecurityErrorEvent; | |
import flash.net.Socket; | |
import flash.system.Security; |
This file contains hidden or 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
// you can also use imports, for example: | |
import java.util.*; | |
class Solution { | |
public int solution(int[] A) { | |
// search for max integer | |
int max = 0; | |
for (int a : A) { | |
// skip negative integers | |
if (a <= 0) { continue; } |
This file contains hidden or 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
class Solution { | |
public int solution(int A, int B, int K) { | |
return B == 0 ? 1 : (B / K - (A == 0 ? -1 : (A-1) / K )); | |
} | |
} |
This file contains hidden or 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
set mapred.job.queue.name=hddq-commrce-mktmisc; | |
set hive.auto.convert.sortmerge.join=true; | |
set hive.optimize.bucketmapjoin=true; | |
set hive.optimize.bucketmapjoin.sortedmerge=true; | |
set hive.auto.convert.sortmerge.join.noconditionaltask=true; | |
set hive.enforce.bucketing=true; | |
set hive.enforce.sorting=true; | |
drop table IF EXISTS pla_bucket_superset; |
OlderNewer