Skip to content

Instantly share code, notes, and snippets.

View kobeumut's full-sized avatar
🏠
Working from home

Umut ADALI kobeumut

🏠
Working from home
View GitHub Profile
@kobeumut
kobeumut / AppServiceProvider.php
Created December 15, 2017 12:09
low version laravel migrate in mysql
//Illuminate\Database\QueryException]
// SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
@kobeumut
kobeumut / wp.sh
Created November 12, 2017 09:46 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
@kobeumut
kobeumut / Substring.kt
Created October 25, 2017 14:55
sometimes you might want to get the last characters of the string or first characters.
var variable = "New Things"
print(variable.take(6)) // # => New Th
print(variable.takeLast(6)) // # => Things
@kobeumut
kobeumut / HashUtils.kt
Created October 25, 2017 14:22
I found Sam Clarke's kit. SHA 512 etc.
package com.samclarke.android.util
import java.security.MessageDigest
/**
* Hashing Utils
* @author Sam Clarke <www.samclarke.com>
* @license MIT
*/
object HashUtils {
@kobeumut
kobeumut / javascript-empty-object-control.js
Created October 24, 2017 07:47
You can check your object is null or empty
var test = {};
if (test==null && isEmpty(test)) {
console.log("is empty");
} else {
console.log("is not empty");
}
function isEmpty(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return false;
@kobeumut
kobeumut / foreach-break.js
Created October 4, 2017 10:56
For loop break is problem for foreach in Javascript. There is no built break in for each. You can do throw like that
var exceptionOfBreak = {};
try {
["a", "b", "c"].forEach(function(el) {
console.log(el);
if (el === "b") throw exceptionOfBreak;
});
} catch (e) {
if (e == exceptionOfBreak) console.log("for loop is break");
}
@kobeumut
kobeumut / Google-apps-script-change-row-color.gs
Last active October 4, 2017 08:25
Change row color and add this row in local data on Google Apps Script
function onEdit(e){
var getRow = e.source.getActiveRange().getRow().toFixed(0);
var newSheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; //I Select First Sheet.
if(newSheet.getSheetId()==SpreadsheetApp.getActiveSheet().getSheetId()){
var rowrange =SpreadsheetApp.getActiveSheet().getDataRange().offset(getRow-1, 0, 1);
rowrange.setBackground("#49fff933");
var cache = PropertiesService.getUserProperties().getProperty("array");
PropertiesService.getUserProperties().setProperty("array",(cache!=undefined||cache!=null)?cache+","+getRow:getRow);
newSheet.appendRow([PropertiesService.getUserProperties().getProperty("array")]); //Show add your row number
}
@kobeumut
kobeumut / kotlin-Restriction-Vetoable.kt
Last active October 3, 2017 13:25
if you only want to use within your restriction you use vetoable
//if you only want to use within your restriction you use vetoable
var name by vetoable("adali") { property: KProperty<*>, oldValue, newValue ->
newValue.startsWith("A")
}
name = "umut"
// # : name = "adali" ->because name not startwith S so
name = "Adanalı"
// # : name = "adanali" -> that's it
@kobeumut
kobeumut / new_id_increase_sql_query.sql
Created September 29, 2017 06:12
New id field sql query with increasing number.
SET @serial=0;
UPDATE table_name SET new_product_id = @serial := @serial+1
//Remove All Empty Columns in the Entire Workbook
function removeEmptyColumns() {
var ss = SpreadsheetApp.getActive();
var allsheets = ss.getSheets();
for (var s in allsheets){
var sheet=allsheets[s]
var maxColumns = sheet.getMaxColumns();
var lastColumn = sheet.getLastColumn();
if (maxColumns-lastColumn != 0){
sheet.deleteColumns(lastColumn+1, maxColumns-lastColumn);