Skip to content

Instantly share code, notes, and snippets.

View ecaybek's full-sized avatar

Eren Can Aybek ecaybek

View GitHub Profile
@ecaybek
ecaybek / swap
Created September 15, 2022 17:34
Generate 3 GB of Swap Partition
# Generates 3 GB of Swap Partition
sudo /bin/dd if=/dev/zero of=/var/swapfile bs=1M count=3072
sudo /sbin/mkswap /var/swapfile
sudo chmod 600 /var/swapfile
sudo /sbin/swapon /var/swapfile
@ecaybek
ecaybek / list2xlsx.R
Created December 26, 2020 15:34
Write a List to Excel File
myList <- list()
for(i in 1:10){
myList[[i]] <- data.frame(a = rnorm(100, 0,1),
b = rnorm(100, 0,1))
}
library(xlsx)
for (i in 1:3){
write.xlsx(myList[i],
file="test.xlsx",
@ecaybek
ecaybek / jamovi-prepare-data-for-efa.R
Last active October 13, 2020 21:44
This code prepares your data for EFA in Jamovi Rj Editor
###### MISSING VALUE IMPLEMENTATION ##########
# Install this packages to System R
remotes::install_github("cran/BaylorEdPsych")
remotes::install_github("cran/mvnmle")
install.packages("mice")
# Select System R in Rj Editor's Settings
# Set your working directory for saving implemented data
setwd("C:/Jamovi")
@ecaybek
ecaybek / mahalanobis-jamovi.R
Created October 5, 2020 00:09
Mahalanbis Distance with Jamovi
#It must be run on Rj Editor module of Jamovi
x.data <- data #data is the jamovi data.
x.data <- na.omit(x.data) #Remove NA values
x.center <- colMeans(x.data)
x.cov <- cov(x.data)
distance <- mahalanobis(x.data, x.center, x.cov)
cutoff <- qchisq(p = 0.999 , df = ncol(x.data)) #Cutoff value. p could be changed to 0.95, 0.99 etc.
x.data[distance > cutoff, ] #Show only outliers
#Source: https://towardsdatascience.com/mahalonobis-distance-and-outlier-detection-in-r-cb9c37576d7d
@ecaybek
ecaybek / mono-left
Created August 10, 2020 15:11
Mono Sound + Only Left Speaker
#In Terminal:
pacmd load-module module-remap-sink sink_name=mono master=$(pacmd list-sinks | grep -m 1 -oP 'name:\s<\K.*(?=>)') channels=2 channel_map=mono,mono
#source: https://askubuntu.com/a/99960
amixer -D pulse set Master 100%,0%
#source: https://superuser.com/a/317297
@ecaybek
ecaybek / plot-antialiasing.R
Created April 12, 2020 22:36
Plot Antialiasing - Rstudio
## This code enables Cairo in Rstudio plot preview
## Source: https://github.com/rstudio/rstudio/issues/2142#issuecomment-582096257
trace(grDevices:::png, quote({
if (missing(type) && missing(antialias)) {
type <- "cairo-png"
antialias <- "subpixel"
}
}), print = FALSE)
@ecaybek
ecaybek / devtools-dependencies
Created February 24, 2020 10:37
R devtools dependencies
sudo apt-get install libcurl4-gnutls-dev libcurl4-openssl-dev libssl-dev libxml2-dev
@ecaybek
ecaybek / ch
Created December 5, 2019 16:39
GNU/Linux > Chrome Profile Selector
#!/bin/bash
profilename=$1
if [[ -z $profilename ]]
then
echo "Please enter a profile name!"
exit
fi
if [[ $profilename = "g" ]]
then
chromium-browser --profile-directory="Profile 1" 1>/dev/null 2>/dev/null & disown
@ecaybek
ecaybek / Par2TIF.R
Last active August 29, 2019 12:04
Par2TIF
# One can create test information functions
# by entering only the item parameters
# using irtplay package.
library(irtplay)
# Creating a dataframe for item parameters
x <- data.frame(item = c("i1", "i2", "i3", "i4", "i5"),
categ = 2,
model = "2PLM",
@ecaybek
ecaybek / save-as-tab.py
Last active March 28, 2018 10:30
Orange3
#I couldn't save my text-mining outputs other format than pickle, which is not very useful for me.
#I can save the output as tab file with the Python script below.
#To my opinion, it's far easier than converting pickle to csv
#Connect the data to a Python Script widget and enter:
import Orange
data = in_data
data.save("C:/Py/1.tab")