Skip to content

Instantly share code, notes, and snippets.

View Ayoush's full-sized avatar
If it's not gonna work,it is worth a try.

Ayoush Chourasia Ayoush

If it's not gonna work,it is worth a try.
  • Pune
View GitHub Profile
Ayoush /
Created November 21, 2023 05:54
two sum
class Solution(object):
def twoSum(self, nums, target):
hash_map = {}
for i in range(len(nums)):
ans = target - nums[i]
if ans in hash_map.keys():
return([hash_map[ans], i])
hash_map[nums[i]] = i
Ayoush /
Created November 21, 2023 05:26
def isAnagram(s, t):
if len(s) != len(t):
return False
s_hash = []
t_hash = []
for i in range(0, len(s)):
if s[i] in t_hash:
s_hash = s_hash + [s[i]]
Ayoush /
Created November 21, 2023 05:12
def containsDuplicate(self, nums):
if len(nums) == 1:
return False
for i in range(1, len(nums)):
if nums[i-1] == nums[i]:
return True
return False
View example.ex
defmodule OtpConceptsProcesses do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, :ok, [])
def init(:ok) do
{:ok, %{}}
View filter_for_tasks_for_criteria.ex
Enum.reduce(params, dynamic(true), fn
{"workspace_id", workspace_id}, dynamic_query ->
[task, project, user_task, time_track],
^dynamic_query and project.workspace_id == ^workspace_id
{"user_ids", user_ids}, dynamic_query ->
user_ids =, ","), fn x -> String.to_integer(x) end)
View example.ex
query =
|> join(:inner, [task], project in Project, on: == task.project_id)
|> join(:inner, [task], user_task in UserTask, on: == user_task.task_id)
|> join(:left, [task], time_track in TimeTracking, on: time_track.task_id ==
|> where(^filter_for_tasks_for_criteria(params))
View scope.c
int main()
int x = 10, y = 20;
// The outer block contains declaration of x and y, so
// following statement is valid and prints 10 and 20
printf("x = %d, y = %d\n", x, y);
// y is declared again, so outer block y is not accessible
View IPCserver.c
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h> //strlen
#include <sys/socket.h>
#include <arpa/inet.h> //inet_addr
#include <unistd.h> //write
#include <pthread.h> //for threading , link with lpthread
#define MAX 10000
//the thread function
View http-server.c
#include <netdb.h> //bzero()
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h> //socket()
#include <arpa/inet.h> //inet_addr
#include <unistd.h> //write
#include <pthread.h> //for threading , link with lpthread
#define MAX 10000
View client.c
#include <stdio.h> //for printf() and scanf()
#include <sys/types.h>
#include <sys/socket.h>//for socket connect send and recieve
#include <netinet/in.h>
#include <unistd.h>//for close()
#include <netdb.h>
#include <fcntl.h>
#include <stdlib.h>//for atoi()
#include <string.h>//for memeset