Skip to content

Instantly share code, notes, and snippets.

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

Daniel Jacales djaquels

🏠
Working from home
View GitHub Profile
@djaquels
djaquels / Program.cs
Last active October 11, 2022 21:51
ColumnOrder Implementation
/* Given the following binary tree
6
/ \
3 4
/ / \
5 1 0
\ /
2 8
/ \
9 7
@djaquels
djaquels / Node.cs
Created October 11, 2022 21:49
Binary Tree Implementation Using C#
using System;
namespace ColumnOrder {
class Node{
private Node _left;
private Node _right;
private int _value;
public Node(int val){
_value = val;
@djaquels
djaquels / transfer_function.py
Last active June 13, 2022 18:05
Transfer Files from GCS to GCS
#add google-cloud-storage == 2.1.0 to requirements.txt
"""
curl -m 70 -X POST https://<cf-url> \
-H "Authorization:bearer $(gcloud auth print-identity-token)" \
-H "Content-Type:application/json" \
-d '{
"source_bucket_name":"<replace-with-bucket-name>",
"destination_bucket_name":"<replace-with-dest-bucket-name>",
"folder":"<folder-to-transfer>/"
@djaquels
djaquels / Bigtable.scala
Last active May 31, 2022 21:38
Bgitable Custom GRPC Channel
val settingsBuilder = BigtableDataSettings.newBuilder()
settingsBuilder.setProjectId("projectId")
settingsBuilder.setInstanceId("instanceId")
settingsBuilder.setAppProfileId("default")
val grpcSettings = EnhancedBigtableStubSettings.defaultGrpcTransportProviderBuilder()
grpcSettings.setMaxInboundMessageSize(550000000)
println("Before Building Client Settings: ")
println(grpcSettings.getMaxInboundMessageSize().toString)
settingsBuilder.stubSettings().setTransportChannelProvider(grpcSettings.build())
val settings = settingsBuilder.build()
@djaquels
djaquels / MetaCodePractice.py
Created May 30, 2022 00:26
Alternative Solution For Meta/Facebook Code Practice Example https://www.facebookrecruiting.com/profile/preparation_hub
#https://www.facebookrecruiting.com/profile/preparation_hub
"""
4
/ \
2 8
/ \ / \
3 N 6 9
\
N N N N N N N 7
n = 10
g = [[3,7],
[6,2],
[10,4],
[4,8],
[6,8],
[3,1],
[2,9],
[2,8],
[6,9],
@djaquels
djaquels / compress-gcs.py
Created March 12, 2022 17:45
Cloud Function to Compress Cloud Storage Folders
from google.cloud import storage
from zipfile import ZipFile
import os
def compress(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
import sys
class Trie:
def __init__(self):
self.childs = {}
self.isEnd = False
def addWord(self,word):
current = self
for w in word:
if w not in current.childs:
@djaquels
djaquels / spiral-matrix.py
Last active June 23, 2021 15:05
Spiral Matrix
def spiralPathMatrix(matrix, n, m):
# right down left up
directions = [1,0,0,0]
verticalLimit = 0
horizontalLimit = 0
iterations = (n * m )
row,col = [0,0]
direction = 0 # we moving right
prev = 0
items = [matrix[0][0]]
@djaquels
djaquels / reversed_polish_evaluator
Created January 17, 2021 02:02
Solve to the reversed polish notation evaluator engine
def eval_expr(operand,a,b):
if operand == '+':
return a + b
elif operand == '-':
return a - b
elif operand == '*':
return a * b
else:
return a / b