Skip to content

Instantly share code, notes, and snippets.

@refik
refik / gist:7407519
Last active December 27, 2015 23:39
euler 1
(define null ())
(define range
(lambda (x)
(cond
((= x 0) (cons 0 null))
(else
(cons x (range (- x 1)))))))
(define sum
@refik
refik / gist:7453478
Created November 13, 2013 18:00
hpacucli
[ 2280.900050] INFO: task hpacucli.real:4583 blocked for more than 120 seconds.
[ 2280.915408] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 2280.945460] hpacucli.real D ffffffff81806240 0 4583 4582 0x00000000
[ 2280.945465] ffff8803e0821a78 0000000000000082 ffffc9000100c000 fbde0f7c4c552c03
[ 2280.945470] ffff8803e0821fd8 ffff8803e0821fd8 ffff8803e0821fd8 00000000000137c0
[ 2280.945474] ffff8804055d1700 ffff8803f6b68000 ffffffffa0017d40 ffffffffa0017d40
[ 2280.945478] Call Trace:
[ 2280.945492] [<ffffffff8165b0cf>] schedule+0x3f/0x60
[ 2280.945496] [<ffffffff8165bed7>] __mutex_lock_slowpath+0xd7/0x150
[ 2280.945500] [<ffffffff8165baea>] mutex_lock+0x2a/0x50
#!/usr/bin/env python
import sys
import time
import psutil
import subprocess
wan_interface = subprocess.check_output([
'/bin/bash',
'-c',
'ifconfig | grep $(host $(hostname) | cut -d \ -f 4) -B1 | '
import socket
import struct
def ip2long(ip):
packedIP = socket.inet_aton(ip)
return struct.unpack("!I", packedIP)[0]
# Handshake
message = struct.pack('!qii', 0x41727101980, 0, 1)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP

Keybase proof

I hereby claim:

  • I am refik on github.
  • I am refik (https://keybase.io/refik) on keybase.
  • I have a public key whose fingerprint is 990A 68C0 D7EF 3B22 B940 23B5 CD04 7237 F1C3 0B1B

To claim this, I am signing this object:

class ConnectingCars:
def minimizeCost(self, positions, lengths):
carts = sorted((positions[i], positions[i] + lengths[i]) for i in xrange(len(positions)))
move = lambda i: 0 if i == 0 else (carts[i][0] - carts[i-1][1]) * min(i, len(carts) - i)
return sum(move(i) for i in xrange(len(positions)))
@refik
refik / gist:ac60c379cb119225e544
Created January 14, 2015 08:29
topcoder final
class ConnectingCars:
def minimizeCost(self, positions, lengths):
carts = sorted((positions[i], positions[i] + lengths[i]) for i in xrange(len(positions)))
return sum((carts[i][0] - carts[i-1][1]) * min(i, len(carts) - i) for i in xrange(1,len(carts)))
# 2 Dakikada Teklif icin ozel AX parametre isimleri #
buildingType = TR(state['building'])
quoteAmount = state['price']
daireSayisi = state['apartment']
blokSayisi = state['block']
product = "monitor: state['monitor']['id'] \n
panel: state['panel']['id'] \n"
ekstra: TR(state['extra']['monitors']]) + TR(state['extra']['panels']])"
@refik
refik / refik-forecast.R
Created December 14, 2016 06:36
Holt winter forecasting for Audio production data
library(tidyverse)
library(forecast)
library(readxl)
tugce_file <- "/Users/refik/Desktop/her madde kodu için winters modeli.xlsx"
output <- "/Users/refik/Desktop/holt-winters.csv"
excel <- read_excel(tugce_file, col_names = FALSE)
products <- excel[5:nrow(excel), 1:30]
colnames(products) <- c(unlist(excel[4, 1:6]),
library(lubridate)
library(tibble)
library(dplyr)
library(tidyr)
t <- ymd_hms("2017/06/14 10:00:00")
tp1 <- ymd_hms("2017/06/15 15:00:00")
# 10:00 T
# 15:30 T + 1