Skip to content

Instantly share code, notes, and snippets.

View chirdeeptomar's full-sized avatar
😀

Chirdeep Tomar chirdeeptomar

😀
  • London, UK
View GitHub Profile
@chirdeeptomar
chirdeeptomar / RebuildSolrIndexes.ps1
Created November 18, 2013 16:29
Powershell script for re-building solr indexes
$indexes = "Search", "Locations"
Clear-Host
echo "Re-building index started"
for ($index = 0; $index -lt $indexes.Length; $index++)
{
$current_index = $indexes[$index]
echo "Processing $current_index"
@chirdeeptomar
chirdeeptomar / DownloadS3Contents.ps1
Last active December 26, 2015 14:49
Downloads items from a S3 bucket
$AccessKey = "xxxxxxxxx";
$SecretKey = "xxxxxxxxx";
$BucketName = "BUCKET";
$items = Get-S3Object -BucketName $BucketName -AccessKey $AccessKey -SecretKey $SecretKey
$items | ForEach-Object -Process {
"Downloading: " + $_.Key | echo;
Read-S3Object -BucketName $BucketName -Key $_.Key -File $_.Key -AccessKey $AccessKey -SecretKey $SecretKey
}
@chirdeeptomar
chirdeeptomar / JsonTypeProvider.fs
Created September 4, 2013 22:15
Example of using JSON Type provider
// NOTE: If warnings appear, you may need to retarget this project to .NET 4.0. Show the Solution
// Pad, right-click on the project node, choose 'Options --> Build --> General' and change the target
// framework to .NET 4.0 or .NET 4.5.
module TypeProviders.Main
open System
open System.IO
open Microsoft.FSharp.Data.TypeProviders
open FSharp.Data
@chirdeeptomar
chirdeeptomar / SqlTypeProvider.fs
Last active December 22, 2015 03:49
Example of using SQL TypeProvider in F#
module DataAccess
open System
open System.Data
open System.Data.Linq
open Microsoft.FSharp.Data.TypeProviders
open Microsoft.FSharp.Linq
type dbSchema = SqlDataConnection<"Data Source=DEV;Initial Catalog=Bookshelf;Integrated Security=SSPI;">
type Book = {
@chirdeeptomar
chirdeeptomar / ArrayJumper.cs
Last active December 21, 2015 21:48
Given an int array, the value in each element note the next index to jump. Start from 0, calculate the number of jumps need to jump out of the array For example {-1} will return 1 jump {2,3,5,2} will require two jump from 0->2->5(out of array)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@chirdeeptomar
chirdeeptomar / RomanNumberConverter.py
Created August 19, 2013 11:15
Converts integer to roman numerals
# Roman Number Converter
romanNumerals = (('M', 1000),
('CM', 900),
('D', 500),
('CD', 400),
('C', 100),
('XC', 90),
('L', 50),
('XL', 40),
@chirdeeptomar
chirdeeptomar / LimesurveyClient.fs
Created May 1, 2013 16:15
F# Client for Limesurvey API
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open RestSharp
open System
[<EntryPoint>]
let main argv =
let url = "http://demo.limesurvey.org/index.php/admin/remotecontrol"
let client = new RestClient(url)
let mutable request = new RestRequest () :> IRestRequest
@chirdeeptomar
chirdeeptomar / CalculatorFunc.cs
Created April 25, 2013 10:00
Applies operations on demand.
using System;
using System.Collections.Generic;
namespace Func
{
class MainClass
{
public static void Main (string[] args)
{
Func<int, int, int> Add = (x, y) => {
@chirdeeptomar
chirdeeptomar / Netflix.fs
Created April 3, 2013 23:13
F# Type Provider Example (Netflix)
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open Microsoft.FSharp.Data.TypeProviders
type Netflix = ODataService<"http://odata.netflix.com/v2/Catalog/">
[<EntryPoint>]
let main argv =
@chirdeeptomar
chirdeeptomar / excel_reader.py
Created December 11, 2012 13:31
Finds duplicate rows in excel 2007
from openpyxl import load_workbook
import os
dir_name = os.path.relpath(os.path.dirname(__file__))
file_name = os.path.join(dir_name, 'Data.xlsx')
unique_items = []
all_items = []