Skip to content

Instantly share code, notes, and snippets.

View edib's full-sized avatar

ibrahim edib kokdemir edib

View GitHub Profile
@edib
edib / zero_file_create.sh
Created December 5, 2015 16:21
bash create many files with number of files parameter
#!/bin/bash
numberoffiles=$1
for i in `seq 1 $numberoffiles`
do dd if=/dev/zero of=`date +%N`.file bs=1024 count=16000
done
@edib
edib / mv2dirs.sh
Created June 12, 2016 15:16
grouping many image files into sub directories
#!/bin/bash
dirno=1
fileno=0
for i in `ls *.JPG`
do
mod=$(($fileno%40))
if [ "$mod" -eq "0" ]
then
dir="g$dirno"
mkdir $dir
package main
import (
"fmt"
)
func main() {
for {
fmt.Print("Enter text: ")
package main
import (
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"time"
)
@edib
edib / fibonacci.plpgdql
Last active July 12, 2016 10:50
returns fibonacci sequence in pl/pgsql
CREATE OR REPLACE FUNCTION fibonacci(num integer)
RETURNS SETOF numeric AS $$
DECLARE
a numeric := 0;
b numeric := 1;
BEGIN
IF (num <= 0)
THEN RETURN;
END IF;
RETURN NEXT a;
@edib
edib / vim command
Created August 8, 2016 06:22
vim add tab character at the top of the some regexed lines
:%s/^Uzunluk\(.*\)$/^I^IUzunluk\1/g
@edib
edib / awk sum
Created August 8, 2016 07:08
awk sum
a file with hours:minutes:seconds
00:38:14
16:31:37
03:49:50
04:14:06
07:21:27
03:10:47
02:30:22
01:45:49
@edib
edib / turtle_rotating_squares.py
Last active September 24, 2016 22:23
rotate number given as command line argument
import turtle
import random
import sys
def r():
return random.randint(0, 255)
screen = turtle.Screen()
screen.bgcolor("#fff")
screen.colormode(255)
&{ ForEach ($esx in Get-VMHost) {
$vCPU = Get-VM -Location $esx | Measure-Object -Property NumCpu -Sum | select -ExpandProperty Sum
$esx | Select Name,
@{N='pCPU cores available';E={$_.NumCpu}},
@{N='vCPU assigned to VMs';E={$vCPU}},
@{N='Ratio';E={[math]::Round($vCPU/$_.NumCpu,1)}},
@{N='CPU Overcommit (%)';E={[Math]::Round(100*(($vCPU - $_.NumCpu) / $_.NumCpu), 1)}}
} } | Export-Csv report.csv -NoTypeInformation -UseCulture
[array]$osNameObject = $null
$vmHosts = Get-VMHost
$i = 0
foreach ($h in $vmHosts) {
Write-Progress -Activity "Going through each host in $vCenter..." -Status "Current Host: $h" -PercentComplete ($i/$vmHosts.Count*100)
$osName = ($h | Get-VM | Get-View).Summary.Config.GuestFullName
[array]$guestOSList += $osName
Write-Verbose "Found OS: $osName"