Skip to content

Instantly share code, notes, and snippets.

View TheRoyalDebugger's full-sized avatar
🏠
Working from home

Dhruv Narayan Singh TheRoyalDebugger

🏠
Working from home
  • AT&T
  • India
View GitHub Profile
@TheRoyalDebugger
TheRoyalDebugger / LongestSubstringKDistinct.java
Created October 12, 2020 08:00 — forked from Schachte/LongestSubstringKDistinct.java
Sliding Window Maximum Sum Subarray
import java.util.*;
class LongestSubstringKDistinct {
public static int findLength(String str, int k) {
int windowStart = 0, maxLength = 0;
Map<Character, Integer> charFrequencyMap = new HashMap<>();
for (int windowEnd = 0; windowEnd < str.length(); windowEnd++) {
char rightChar = str.charAt(windowEnd);
charFrequencyMap.put(rightChar, charFrequencyMap.getOrDefault(rightChar, 0) + 1);
@TheRoyalDebugger
TheRoyalDebugger / gist:3e4ac185d72526f3a8d2d42115708af2
Created January 31, 2019 19:10 — forked from kublaios/gist:f01cdf4369c86ddd6d71
Making a PEM File for iOS Push Notifications (From Ray Wenderlich's tutorial)
# Convert the .cer file into a .pem file:
$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
# Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem
# Finally, combine the certificate and key into a single .pem file
$ cat PushChatCert.pem PushChatKey.pem > ck.pem
# At this point it’s a good idea to test whether the certificate works.
@TheRoyalDebugger
TheRoyalDebugger / countries.json
Created August 28, 2018 13:16 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@TheRoyalDebugger
TheRoyalDebugger / 1a-LiveCameraView.m
Created May 23, 2018 14:32 — forked from jamztang/1a-LiveCameraView.m
My first hackathon experience - 12 hours of hacking and building the essentials. https://medium.com/p/3db44088db70
- (void)viewDidLoad {
[super viewDidLoad];
self.videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionFront];
self.videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
// self.avatarView is a non full screen GPUImageView instance
// created in Storyboard
[self.videoCamera addTarget:self.avatarView];
[self.videoCamera startCameraCapture];
Install FFmpeg
https://www.faqforge.com/linux/how-to-install-ffmpeg-on-ubuntu-14-04/
Nginx server:
https://blog.100tb.com/how-to-set-up-an-rtmp-server-on-ubuntu-linux-using-nginx
@TheRoyalDebugger
TheRoyalDebugger / BinarySearch.cpp
Last active October 21, 2017 14:49
Binary Search: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or th…
#include<iostream>
using namespace std;
bool isBinarySearchFoundElement(int* arrData,int searchElement,int left, int right){
if(left > right){
return false;
}
int mid = left + (right-left)/2;
if(arrData[mid] == searchElement){
return true;
@TheRoyalDebugger
TheRoyalDebugger / MergeSort.cpp
Last active October 21, 2017 12:06
Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves. The mergeSortedArrays() function is used for merging two halves.
#include <iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
void mergeSortedArrays(int* arrData,int *arrLeft,int leftCount,int* arrRight, int rightCount){
int i =0,j=0,k=0;
while(i < leftCount && j < rightCount){
if(arrLeft[i] < arrRight[j]){
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Player {
string name;
@TheRoyalDebugger
TheRoyalDebugger / QuickSort.cpp
Last active October 20, 2017 05:55
QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.
#include <iostream>
using namespace std;
int getPartitionPoint(int* arrData, int low, int high){
//Set pivot
int pivot = arrData[(low+high)/2];
while(low < high){
//Move pointer for left half
while(arrData[low] < pivot){
extension Bundle {
var apiBaseURL: String {
return object(forInfoDictionaryKey: "serverBaseURL") as? String ?? ""
}
}
//And call it from the code like this:
let baseURL = Bundle.main.apiBaseURL