Skip to content

Instantly share code, notes, and snippets.

View ti-ka's full-sized avatar
🎯
Focusing

Tika Pahadi ti-ka

🎯
Focusing
View GitHub Profile
// Insertion Sort
// Insertion sort is a comparison-based algorithm that builds a final sorted array one element at a time.
// It iterates through an input array and removes one element per iteration, finds the place the element belongs in the array, and then places it there.
// https://brilliant.org/wiki/sorting-algorithms/
var array = [47,59,98,98,91,10,0,9,14,12]
console.log(insertionSort(array))
@ti-ka
ti-ka / binary-search.js
Last active January 31, 2018 19:25
Binary search on a sorted array using recursion: https://jsbin.com/pilitor/edit?js,console
// Task:
// Find an item in an sorted array.
var array = [1,3,4,6,7,8,8,9,10,56,102,200,230]
var item = 200
var globalCounter = 0
console.log(binarySearch(array, item))
public exportFile(filename: string, type: string, data: any) {
const blob = new Blob([data], {type: type});
this.exportBlob(blob, filename);
}
public exportBlob(blob: Blob, filename: string) {
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveBlob(blob, filename);
} else {
const elem = window.document.createElement('a');
import {Component, forwardRef, Input} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Principal } from '../../models/entities';
import { Exportable } from './../Exportable';
@Component({
selector: 'edit-principal',
templateUrl: './edit.html',
styleUrls: ['../component.css'],
providers: [{provide: NG_VALUE_ACCESSOR,
@ti-ka
ti-ka / csv.cs
Last active August 2, 2017 05:54
CSV to C# List of Cells
private List<Dictionary<string, object>> CSVToListOfDictionary(string csv)
{
var items = new List<Dictionary<string, object>>();
var headers = new List<object>();
var lines = csv.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
for (var i = 0; i < lines.Length; i++)
{
var line = lines[i].Trim();
@ti-ka
ti-ka / holidays.php
Created July 18, 2017 07:18
holidays
<?php
$holidays = [
// Start of Holidays
// Year by year
"2012-07-03", "2012-07-07", "2012-07-14", "2012-07-16", "2012-07-17",
"2012-07-21", "2012-07-24", "2012-07-28",
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
try {
//Assuming the location and filename as below
var url = "http://localhost:8080/homestead.txt";
$.ajax(url)
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ti-ka
ti-ka / Retrive Json Data from Mysql.sql
Created March 10, 2017 16:34
If you have saved data into a field as json, you can use mysql to retrieve each field. It may be useful in migrating database when you have decided that using JSON in a database was not a good idea.
/* APPENDIX 1-B: CLEANUP
This makes this sql query re-run able */
DROP TABLE IF EXISTS JSON_TABLE;
DROP TABLE IF EXISTS SPLIT_TABLE;
DROP VIEW IF EXISTS SPLIT_VIEW;
/* APPENDIX 1-B: Prepare TABLE
Let's say this is an example table */
@ti-ka
ti-ka / GenericRepository.cs
Last active March 23, 2024 00:45
Generic Repository with Tracking and No Tracking Options
using Prognose.Domain;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
namespace App.Domain
{
public interface IEntity