This file contains 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
<?php | |
function out($text, $status) { | |
$str = ''; | |
switch($status) { | |
case 'SUCCESS': | |
$str = "[42m"; | |
break; | |
case 'FAIL': | |
$str = "[41m"; |
This file contains 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
<?php | |
function rolling_curl($urls, $callback, $custom_options = null) { | |
// make sure the rolling window isn't greater than the # of urls | |
$rolling_window = 5; | |
$rolling_window = (sizeof($urls) < $rolling_window) ? sizeof($urls) : $rolling_window; | |
$master = curl_multi_init(); | |
$curl_arr = array(); |
This file contains 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 utils; | |
import org.apache.commons.cli.Options; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.hbase.Cell; | |
import org.apache.hadoop.hbase.CellScanner; | |
import org.apache.hadoop.hbase.CellUtil; | |
import org.apache.hadoop.hbase.HBaseConfiguration; | |
import org.apache.hadoop.hbase.client.Put; | |
import org.apache.hadoop.hbase.client.Result; |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import zipfile | |
file = zipfile.ZipFile(sys.argv[1], "r"); | |
for name in file.namelist(): | |
utf8name=name.decode('gbk') |
This file contains 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
/** | |
* Render the given HttpException. | |
* call 'abort(errcode)' in code | |
* | |
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e | |
* @return \Symfony\Component\HttpFoundation\Response | |
*/ | |
protected function renderHttpException(HttpException $e) | |
{ | |
if (!config('app.debug') && view()->exists('errors.'.$e->getStatusCode())) |
This file contains 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 learn; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.hbase.HBaseConfiguration; | |
import org.apache.hadoop.hbase.client.Put; | |
import org.apache.hadoop.hbase.client.Result; | |
import org.apache.hadoop.hbase.client.Scan; | |
import org.apache.hadoop.hbase.filter.CompareFilter; | |
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; | |
import org.apache.hadoop.hbase.io.ImmutableBytesWritable; |
This file contains 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 learn; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.hbase.HBaseConfiguration; | |
import org.apache.hadoop.hbase.HColumnDescriptor; | |
import org.apache.hadoop.hbase.HTableDescriptor; | |
import org.apache.hadoop.hbase.TableName; | |
import org.apache.hadoop.hbase.client.*; | |
import org.apache.hadoop.hbase.util.Bytes; |
This file contains 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
# from: http://stackoverflow.com/questions/2148119/how-to-convert-an-xml-string-to-a-dictionary-in-python | |
class XmlListConfig(list): | |
def __init__(self, aList): | |
for element in aList: | |
if element: | |
# treat like dict | |
if len(element) == 1 or element[0].tag != element[1].tag: | |
self.append(XmlDictConfig(element)) | |
# treat like list | |
elif element[0].tag == element[1].tag: |
This file contains 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
@RequestMapping(value = "/template/{filename}", method = {RequestMethod.GET}) | |
public ResponseEntity<byte[]> downloadTemplate(HttpServletRequest request, @PathVariable("filename") String filename) { | |
String prefix = request.getServletContext().getRealPath(ConstantsManager.EXCEL_TEMPLATE_PATH); | |
filename += ".xls"; | |
String filepath = prefix + "/" + filename; | |
File file = new File(filepath); | |
HttpHeaders headers = new HttpHeaders(); | |
ResponseEntity<byte[]> entity = null; | |
try { | |
String utfFileName = new String(filename.getBytes("UTF-8"), "iso-8859-1"); |
This file contains 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
/** | |
* utf8 byte to unicode string | |
* @param utf8Bytes | |
* @returns {string} | |
*/ | |
function utf8ByteToUnicodeStr(utf8Bytes){ | |
var unicodeStr =""; | |
for (var pos = 0; pos < utf8Bytes.length;){ | |
var flag= utf8Bytes[pos]; | |
var unicode = 0 ; |
OlderNewer