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
@shinyzhu
shinyzhu / ppt-watermarks-removal.vbs
Last active August 29, 2015 14:01
Remove some watermarks in Powerpoint template files
Option Explicit
Sub RemoveWatermarks()
'image watermark values
Dim imgWidth As Double, imgHeight As Double, delta As Double
imgWidth = 100.12
imgHeight = 100.12
delta = 0.1
@shinyzhu
shinyzhu / add-progressbar.vbs
Created May 18, 2014 01:37
Add a progress bar to each slide bottom of PowerPoint.
Option Explicit
Sub AddProgressBar()
On Error Resume Next
With ActivePresentation
For X = 1 To .Slides.Count
.Slides(X).Shapes("PB").Delete
Set s = .Slides(X).Shapes.AddShape(msoShapeRectangle, _
//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);
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
<?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>