Skip to content

Instantly share code, notes, and snippets.

View cakriwut's full-sized avatar

Riwut Libinuko cakriwut

  • ItsZap Inc.
  • Singapore
View GitHub Profile
@cakriwut
cakriwut / DeleteListItems.ps1
Last active August 29, 2020 17:01
PowerShell to delete SharePoint list items in batch mode.
function DeleteListItems{
<#
.SYNOPSIS
Deletes SharePoint List Items in batch
.DESCRIPTION
Deleted SharePoint List items in batch and provide sleep between batch. By default, it will delete all List Items.
You can delete List Items based on the CAML Query input parameter.
.PARAMETER ListUrl
@cakriwut
cakriwut / ServiceBaseExtensions.cs
Created December 29, 2015 14:58
ServiceStack Extensions to POST multiple files along with dto.
///<summary>
/// ServiceClient Base Extensions
/// Author: Riwut Libinuko
/// Created Date: 29/12/2015
/// Website : http://blog.libinuko.com
/// Copyright(c) 2015
/// Use PostFilesWithRequest<TResponse>(...) , to POST metadata and multiple files attachment in single request
///</summary>
public static class ServiceClientBaseExtensions
{
@cakriwut
cakriwut / FileStreamInfo.cs
Created December 29, 2015 15:02
FileStreamInfo.cs to be used with PostFilesWithRequest .
///<summary>
///When POSTing using PostFilesWithRequest, each individual files posted must bring metadata. So that the class can craete multipart request.
///</summary>
public class FileStreamInfo
{
public Stream InputStream { get; set; }
public string Filename { get; set; }
}
@cakriwut
cakriwut / CsvActionResult.cs
Created March 2, 2016 15:42 — forked from simonech/CsvActionResult.cs
ActionResult for ASP.NET MVC that returns a CSV file from any list of objects
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace webnetconf.website.Helpers
@cakriwut
cakriwut / RemoveFromGit.cmd
Created August 22, 2016 23:50
Remove file/folder from GIT repo permanently
REM Remove folder Sample/packages from GIT repository
git --filter-branch --index-filter "git rm --cached --ignore-unmatch -rf Sample/package" --prune-empty --tag-name-filter cat -- --all
REM Remove file Sample/packages/filetoremove.txt from GIT repository
git --filter-branch --index-filter "git rm --cached --ignore-unmatch Sample/package/filetoremove.txt" --prune-empty --tag-name-filter cat -- --all
REM push the result to origin
git push origin --force --all
git push origin --force --tags
@cakriwut
cakriwut / RenameGitBranch.cmd
Created August 22, 2016 23:58
Rename git branch
REM rename branch in local
git branch -m old_branch new_branch
REM delete old branch in ORIGIN
git push origin :old_branch
REM set new branch to track ORIGIN
git push --set-upstream origin new_branch
REM re-sync remote branch to local, removing deleted remote
git fetch origin --prune
@cakriwut
cakriwut / MongoDb-FilteredArray-Source.js
Last active September 10, 2016 02:43
How to filter array inside mongoDB document, so it will return a document with filtered array inside.
/* 1 */
{
"_id" : "joe",
"name" : "Joe Bookreader",
"addresses" : [
{
"street" : "123 Fake Street",
"city" : "Faketon",
"state" : "MA",
"zip" : "12345"
@cakriwut
cakriwut / DetikApi.ps1
Created October 5, 2016 15:19
How to download URL news link from www.detik.com
# Defines date range of the news
$startDate = Get-Date "2016-01-01"
$endDate = Get-Date
# Defines file capture location
$fileCapture = "C:\temp\detik.txt"
$detikApi = "http://apis.detik.com/v1/indeks?limit=500&channelid=10&gt={0:yyyy-MM-dd HH:mm:ss}&lt={1:yyyy-MM-dd HH:mm:ss}"
$currentDate = $startDate
do {
$nextDate = $currentDate.AddMonths(1)
@cakriwut
cakriwut / DetikRSS.ps1
Created October 5, 2016 15:26
How to download URL news link from detik.com using RSS feed
# Defines file capture location
$fileCapture = "C:\temp\detik.txt"
# List of target RSS - you can add more
$targetRSS = "detikcom_nasional", "detikcom_internasional", "detikcom_bbc","detikcom_lapsus","detikcom_wawancara"," detikcom_prokontra"
$targetRSS |% {
$url = "http://rss.detik.com/index.php/" + $_
$targetXml = "C:\temp\" + $_ + ".xml"
Invoke-WebRequest -Uri $url -OutFile $targetXml -ErrorAction Stop
@cakriwut
cakriwut / web.config
Last active October 22, 2016 15:46
IIS Reverse Proxy Sample Rule
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxy" stopProcessing="true">
<match url=".*" />