Skip to content

Instantly share code, notes, and snippets.

View cptangry's full-sized avatar

Gökhan Çağlar cptangry

View GitHub Profile
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
[[Serializable]
public class TokenClassName
{
public string access_token;
}
static final int frequency = 44100;
static final int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
static final int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
boolean isPlaying;
int playBufSize;
Socket socket;
AudioTrack audioTrack;
playBufSize=AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, frequency, channelConfiguration, audioEncoding, playBufSize, AudioTrack.MODE_STREAM);
@cptangry
cptangry / tweakmyfedora.sh
Last active June 19, 2018 20:57
Fedora Automatizaion Script
#!/bin/bash
# Forked respin respun forked stolen and modified by Cptangry
# Tested w/ Fedora 28 Gnome
# Version 1.0.0
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root type: sudo ./installscript"
exit 1
else
#Update and Upgrade
require 'minitest/autorun'
module Gigasecond
def self.from(time_object)
time_object + (10**9)
end
end
class GigasecondTest < Minitest::Test
require 'minitest/autorun'
module Hamming
def self.compute(str1, str2)
if str1.length == str2.length
distance = str1.chars.zip(str2.chars).count { |l, r| l != r }
print "Hamming Distance for '#{str1}' & '#{str2}' : #{distance}", "\n"
distance
else
puts "ERROR! : The Hamming distance is only defined for sequences of equal length"
MAP = -> (f, *coll) { mem = []; coll.each { |i| mem << [i].flatten.map(&f) }; mem } # Bir kolaksiyon yada değeri alıp bir fonksiyona geçer
ARR_GEN = -> (x, y, z) { Array.new(x) { rand(y..z) } } # Belirtilen değer aralıklarında Belirtilen uzunlukta bir dizi yaratır
INC = -> (x) { x + 1 } # Bir arttır
DEC = -> (x) { x - 1 } # Bir azalt
dizi1 = [3, 5, 8]
dizi2 = ARR_GEN.(5, 1, 5)
@cptangry
cptangry / enum.rb
Created July 30, 2017 11:07
Ruby Enumerator & Generators
#!/usr/bin/env ruby
# -*- coding: utf-8
# İLERİ SEVİYE DERSLER 1 :: ENUMARATORLER
ucgensel_sayilar = Enumerator.new do |y|
n = 0
sayac = 1
loop do
n += sayac
@cptangry
cptangry / tube2mp3.rb
Last active July 25, 2017 11:50
Ruby ile bir youtube playlistindeki linkleri ve video adlarını almak(format atacağım karalama olarak yazmıştım css sini çözmek için)
# coding: utf-8
require 'nokogiri'
require 'open-uri'
require 'yaml'
print "Bir Youtube Playlist Linki Girin: " unless ARGV[0] # İlk parametre boşsa yazdır
# Parametre verilmemişse kullanıcı playlist linki girecek
PLAYLIST = ARGV[0] || gets.chomp
SAYFA = Nokogiri::HTML(open(PLAYLIST).read) # SAYFA sabitine playlist linki çözümlenecek
@cptangry
cptangry / round.go
Created July 22, 2017 07:15
Büyük hizmet! GO Programlama Dili için Round Fonksiyonu
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
digit := pow * val
_, div := math.Modf(digit)
@cptangry
cptangry / lets.go
Last active January 28, 2024 13:07
Tek dosyada Go dilinin temel konuları ve örnekler
package main //Çalıştrılacak her Go kaynak dosyasında yer almalıdır.
// Go Dilinde tek satırlık yorum/açıklama
import (
"fmt" // Standart kütüphaneyi projemize dahil ettik
"io/ioutil" // Temel io işlemleri
"log" // log
"math" // Matematiksel işlem ve değer tanımlarını içeren kütüphaneyi içe aktardık
"net/http"
"os" // İşletim sistemi işlemleri