Skip to content

Instantly share code, notes, and snippets.

View shinyzhu's full-sized avatar
🗣️
Talk to me

Shiny shinyzhu

🗣️
Talk to me
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace SocialKit.ImageUtil
{
/// <summary>
/// Provides methods for combine images into a single one.
/// </summary>
@shinyzhu
shinyzhu / HTTP mutilpart POST
Created August 11, 2010 09:23
HTTP mutilpart POST
POST http://172.21.120.186:8001/rest.aspx HTTP/1.1
Host: 172.21.120.186:8001
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://172.21.120.186:8001/upload.html
//Save 100 quality JPEG image in C#
var combinedImage = ImageCombiner.Combine(16, images);
var encoder = ImageCodecInfo.GetImageEncoders().FirstOrDefault(e => e.MimeType == "image/jpeg");
var encoderParams = new EncoderParameters();
encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
combinedImage.Save("wall_big.jpg", encoder, encoderParams);
<?php
#Does the $str ends with $end?
function str_ends_with($str, $end){
return (substr($str, strlen($str) - strlen($end)) === $end);
}
?>
/// <summary>
/// Solution for calculate xy=total, x-y -> 0.
/// Reference: http://www.wolframalpha.com/input/?i=xy%3D200,+x%3E0
/// </summary>
/// <param name="total">The integer to calculate.</param>
/// <returns>x,y pair, x &lt;= y.</returns>
public static KeyValuePair<int, int> MinXPlusY(int total)
{
var allXplusY = Enumerable.Range(1, total)
.Where(i => total % i == 0 && i <= total / i)
<?php
#Solution for calculating xy=total, x-y->0.
#y is always equal or greater than x
#Reference: http://www.wolframalpha.com/input/?i=xy%3D200,+x%3E0
function min_xy($total){
$all_xy = array();
$min = $total;//minimum number
$min_idx = -1;//minium number position in $all_xy
@shinyzhu
shinyzhu / gist:552657
Created August 27, 2010 02:25
DAL for SAE
<?php
/*
Data Access Layer for FansWall(http://fanswall.sinaapp.com)
Author: Shiny Zhu(http://t.sina.com.cn/shinyzhu)
*/
class DAL{
private $server, $username, $password, $db;
private $link;
private $result;
<!-- set these 2 attributes to hide secondary y-axis value in mscombidy2d.swf of FusionCharts -->
<chart showDivLineSecondaryValue="0" showSecondaryLimits="0">
</chart>
@shinyzhu
shinyzhu / gist:836796
Created February 21, 2011 08:01
read info.plist
NSBundle *mainBudle=[NSBundle mainBundle];
NSString *hgURL = [mainBudle objectForInfoDictionaryKey:@"HGGuideURL"];
@shinyzhu
shinyzhu / Base58Encoder.h
Created July 8, 2011 03:16
ObjC implementation of base 58 encoding for Flic.kr URLs.
@interface Base58Encoder : NSObject {
}
+ (NSString *)base58EncodedValue:(long long)num;
@end