Skip to content

Instantly share code, notes, and snippets.

View cagdass's full-sized avatar
🐟
Gonna eat halibut tonight

Çağdaş cagdass

🐟
Gonna eat halibut tonight
View GitHub Profile
@cagdass
cagdass / sup.erl
Created January 29, 2018 13:40
Supervisor template
%%% _________________________________________________________________________
%%%
%%%
%%% xxxx supervisor for xxxx
%%%
%%% _________________________________________________________________________
-module(xxxx).
-behaviour(supervisor).
@cagdass
cagdass / slack.sh
Last active October 25, 2017 08:05
Automized slack status
#!/bin/bash
# The idea and the most of the script is not mine, I saw it on reddit
slack_token=""
workwifi="Port56"
homewifi="TP-LINK_3E7FDB"
homewifi2=""
ssid=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
if [ "$ssid" == "$workwifi" ]; then
/usr/bin/curl https://slack.com/api/users.profile.set --data 'token='$slack_token'&profile=%7B%22status_text%22%3A%22%40the%20office%22%2C%22status_emoji%22%3A%22%22%7D' > /dev/null
elif [ "$ssid" == "$homewifi" ] || [ "$ssid" == "$homewifi2" ]; then
-module(pbkdf2).
-export([generate/3]).
exor(Binary1, Binary2) ->
exor(binary_to_list(Binary1), binary_to_list(Binary2), []).
exor([], [], Result) -> list_to_binary(lists:reverse(Result));
exor([H1|Binary1], [H2|Binary2], Result) ->
exor(Binary1, Binary2, [H1 bxor H2 | Result]).
generate(Password, Salt, IterationCount) ->
@cagdass
cagdass / magic.erl
Last active July 23, 2017 23:05
Magic lines of Erlang for easy retrieval, mostly from other people's Erlang code on Hackerrank
% Spell 1: Read a list of integers from a line of input the cool way.
% Example pattern, includes the space character and the new line character as delimiter.
CP = binary:compile_pattern([<<" ">>, <<$\n>>]),
% Set the IO device to send binary data.
ok = io:setopts([binary]),
% Function to read a line, split on given delimiter and return a list of integers.
read_int_line(CP) ->
{ok, Line} = file:read_line(standard_io),
[binary_to_integer(X) || X <- binary:split(Line, CP, [global, trim_all])].
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import urllib2
from bs4 import BeautifulSoup
base_url = "https://stars.bilkent.edu.tr/syllabus/view/CS/"
base_url2 = "/20161?section=1"
courses = [101, 102, 201, 202, 223, 224, 315, 319, 342, 353, 425, 426, 473, 476, 481, 484, 464, 421, 101, 102, 132, 225, 230]
@cagdass
cagdass / ml-peer-grade.py
Created December 28, 2016 03:14
Easy peer grading for lucky CS464 students @CSBilkent
#!/usr/bin/python
import sys
if len(sys.argv) != 6:
print '<usage> ./ml-peer-grade.py [YOUR_ID] [YOUR_LAST_NAME] [LAST_NAME_1] [LAST_NAME_2] [LAST_NAME_3]'
else:
args = sys.argv[1:]
f = open('{}.txt'.format(args[0]), 'w')
s = "{0[0]} {0[1]}\n{0[2]} 5\n{0[3]} 5\n{0[4]} 5\n".format(args)
f.write(s)
f.close()
@cagdass
cagdass / A working tex tabular!
Created December 18, 2016 13:21
A working tex tabular!
\begin{table}[h!]
\begin{center}
\begin{tabular}{||c | c | c | c||}
\hline
Number of Clusters & Class Entropy & Cluster Entropy & Overall Entropy \\ [0.5ex]
\hline
2 & 0.194755 & 3.05406 & 1.624407 \\
\hline
3 & 0.725162 & 3.038609 & 1.881886 \\
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void) {
unsigned long long m = 1;
int i;
for (i = 0; i < 64; i++) {
m = m << 1;
m = m | 1;
@cagdass
cagdass / kmp.c
Created October 3, 2016 19:19
Knuth-Morris-Pratt algorithm implementation in C
#include <stdlib.h>
#include <string.h>
void failure(char* pattern, int* f);
int kmp(char* t, char* p);
int* init_array(int size) {
int* arr = (int*)malloc(size * sizeof(int));
int i;
for(i = 0; i < size; i++) {
@cagdass
cagdass / ba.sh
Last active September 2, 2016 23:10
Diinirysizing texts. Inspired by a meme like this: http://cgds.me/diinirys
#!/bin/bash
# <usage>: bash ba.sh [your_text]
echo $1 | tr 'aieou' 'i'