Skip to content

Instantly share code, notes, and snippets.

View uzbekdev1's full-sized avatar
🌴
On vacation

Elyor Latipov uzbekdev1

🌴
On vacation
View GitHub Profile
@uzbekdev1
uzbekdev1 / LICENSE.txt
Created April 8, 2019 16:23
Date.prototype.toJSON
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 Chris Hallberg <http://crhallberg.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
function subsequent<T>(
count: number,
operator: (source: Observable<T>) => Observable<T>
): (source: Observable<T>) => Observable<T> {
return (source: Observable<T>) => new Observable<T>(observer => {
const published = source.pipe(publish()) as ConnectableObservable<T>;
const concatenated = concat(
published.pipe(take(count)),
published.pipe(operator)
);
@uzbekdev1
uzbekdev1 / api.module.ts
Created March 14, 2019 08:55 — forked from Toilal/api.module.ts
@auth0/angular2-jwt Authorization Service and HttpInterceptor supporting JWT Refresh Token (Angular 4.3+ & 5+)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { JWT_OPTIONS, JwtInterceptor, JwtModule } from '@auth0/angular-jwt';
import { AuthorizationService } from './authorization.service';
import { environment } from '../../environments/environment';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { RefreshTokenInterceptor } from './refresh-token-interceptor';
function jwtOptionsFactory (authorizationService: AuthorizationService) {
return {
HOLY SMOKES! This one was very troublesome, but I figured it out after days of trying.
So, there are a lot of partial answers out there, but this should be complete. You cannot from what I have seen, include jquery-ui in your angular-cli and the index. The plugin inclusions will be overwritten and jquery as a global will be undefined. I couldn't get it to work by using just the angular-cli.json, but I did get it to work by only using index inclusion.
Here is what needs to be done to only use index script inclusion for jquery/jquery-ui.
1: Uninstall jquery and jquery-ui and remove it from the package.json
npm uninstall --save jquery jquery-ui
2: Delete the node_modules folder
@uzbekdev1
uzbekdev1 / arrayBufferToString.js
Created March 3, 2019 15:20 — forked from skratchdot/arrayBufferToString.js
Array Buffer -> String and String -> ArrayBuffer conversions in javascript
// source: http://stackoverflow.com/a/11058858
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}
@uzbekdev1
uzbekdev1 / MD5.cs
Created March 1, 2019 11:31 — forked from jasonyost/MD5.cs
Create MD5 from string in C#
public static string MD5Hash(string input)
{
StringBuilder hash = new StringBuilder();
MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider();
byte[] bytes = md5provider.ComputeHash(new UTF8Encoding().GetBytes(input));
for (int i = 0; i < bytes.Length; i++)
{
hash.Append(bytes[i].ToString("x2"));
}
/*
Task Description
interval_map<K,V> is a data structure that efficiently associates intervals of keys of type K with values of type V. Your task is to implement the assign member function of this data structure, which is outlined below.
interval_map<K, V> is implemented on top of std::map. In case you are not entirely sure which functions std::map provides, what they do and which guarantees they provide, we provide an excerpt of the C++ standard here:
Each key-value-pair (k,v) in the std::map means that the value v is associated with the interval from k (including) to the next key (excluding) in the std::map.
Example: the std::map (0,'A'), (3,'B'), (5,'A') represents the mapping
@uzbekdev1
uzbekdev1 / gist:44bb40fe12bb71749c7798a5ea163a42
Created February 22, 2019 10:10 — forked from zelid/gist:6965002
Examples of BulkInsert for PostgreSQL, MySQL and MS SQL using ServiceStack OrmLite. Work in progress...
public static void BulkInsertNpgsql<T>(this IDbConnection dbConn, IEnumerable<T> list, IEnumerable<string> insertFields = null)
{
if (list == null) return;
if (list.Count() < 1) return;
var objWithAttributes = list.FirstOrDefault();
var modelDef = OrmLiteConfig.GetModelDefinition(objWithAttributes.GetType());
if (insertFields == null) insertFields = new List<string>();
@uzbekdev1
uzbekdev1 / gist:66aa4d2ee9a66206f486bf62aaa16d55
Created February 22, 2019 10:10 — forked from zelid/gist:6965002
Examples of BulkInsert for PostgreSQL, MySQL and MS SQL using ServiceStack OrmLite. Work in progress...
public static void BulkInsertNpgsql<T>(this IDbConnection dbConn, IEnumerable<T> list, IEnumerable<string> insertFields = null)
{
if (list == null) return;
if (list.Count() < 1) return;
var objWithAttributes = list.FirstOrDefault();
var modelDef = OrmLiteConfig.GetModelDefinition(objWithAttributes.GetType());
if (insertFields == null) insertFields = new List<string>();
@uzbekdev1
uzbekdev1 / Program.cs
Created February 14, 2019 11:13 — forked from open-ruic/Program.cs
C# RSA Key Utils
using System;
namespace PKCS1ToPKCS8Application
{
class Program
{
static void Main(string[] args)
{
byte[] importedPrivateKeyBytes = Convert.FromBase64String("MIIEowIBAAKCAQEAtuHuMvnE3fYz/eom8mF7xxLXPETjfUpVYHL6AUVwXKKCrZ6uFszh2bY7ADoiIpuPTS0NVNYeKLlu6T59qzyr0bnT8KgXdZJFVzYWIh8VOLTb2zghlu8BeBoJP9t/a34Mj7gGJUZWBgECopEGCXrFwyIvXSW0JU5YrJinyyPhUjUXLeyowJUXoLwEafOHBRRiZZv1SNlntQOAenHFB/1uv2Y5xmdHm7xl+jjeo469u+pY535RCekmam9hWbZcn/WZEf9BZEmE2i4v7Qj72V92LrSUSSjF6w6lgU3B+Byu0XR8ZeUjD+FP9ZKvJyEtxlxOVaADQ+/udghUr1PnfXIHRQIDAQABAoIBAHG1UBFJ0unfJrx9VfHmQruoL0M94eQIz8TEOEWKEy7FrFKfEscCZHqlH1Io0wiJiDQICv3wk5fmk9taC3DorDweOnSrTsq/Q3XSHzjf8qXrbbeD0v6xZEx0g8O8iiEfolfJp6iNbvcUsbq6SPKj70pAewqDYtq/N8s4rztS98nQQ5PAQ10Zv3X910lc0vnPlPKew4y7w6hwb/pbiEBLbbV9tYAVaAm63n/EYxjo3UCRA0BJZxhJbRdEQzCEzClXlo6txx7nGQz/omv574P22ASCAfyrFNhaT20DR+ilIXe+edBpJehD6Q/lpO56STawb9xCAk6+aerM5dcIBMTETRECgYEA3RdnfpY1Z8KtOT1rVUeI094vylP1HONrcXNSsV0sbNPSwoK91UpO0mfsLLWxLtjvX52yixhfKxQ0QLYq3nyC8SRj2GE07aO1HZ81MI/9Y6ynJkw+