Skip to content

Instantly share code, notes, and snippets.

@bembengarifin
bembengarifin / gist:be692a3445463a25dec5
Created December 28, 2014 16:09
Iterate numbers with recursive
IEnumerable<int[]> IterateWithReverse(int lower = 0, int upper = 10, int depth = 10, int[] slots = null)
{
if (slots == null) slots = new int[depth];
for (int i = lower; i < upper; i++)
{
slots[depth - 1] = i;
if (depth > 1)
foreach (var x in IterateWithReverse(lower, upper, depth - 1, slots)) yield return x;
else
@bembengarifin
bembengarifin / gist:9caeeb67aba9e9d55326
Created February 6, 2015 02:56
Top Coder Barclays
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
namespace TopCoderBarclays
{
[TestClass]
public class UnitTest1
{
[TestMethod]
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace LambdaExpressionTraining
{
@bembengarifin
bembengarifin / gist:fd00e3ff956545a431fe
Created July 13, 2015 05:21
Generic & Lambda Expression
We couldn’t find that file to show.
@bembengarifin
bembengarifin / gist:2ab295b1570c40194089
Created July 13, 2015 05:21
Generic & Lambda Expression
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GenericTypeCollection
{
class Car
@bembengarifin
bembengarifin / mongoDB.js
Created July 29, 2015 04:21
MongoDB CRUD Examples
db.persons.insert( { fname : "John" , lname : "Doe", gender : "M" })
db.persons.insert(
[
{ fname : "Jane" , lname : "Doe", gender : "F" },
{ fname : "James" , lname : "Bond", gender : "M", Age : 31 },
{ fname : "Jack" , lname : "Daniel", Age : 24 },
])
db.persons.find (
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Calculator
{
public class Position
{
public string Trader { get; set; }
@bembengarifin
bembengarifin / upsert_table.sql
Last active April 24, 2020 08:01
mysql bulk insert, with duplicate key update (upsert), and with conditional data update
/*
references:
- https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
- https://stackoverflow.com/questions/32777081/bulk-insert-and-update-in-mysql
- https://thewebfellas.com/blog/conditional-duplicate-key-updates-with-mysql
*/
/* create a new database and use it */
drop database if exists test_upsert;
create database test_upsert;