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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / embedded-file-viewer.md
Created December 17, 2017 19:06 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

require 'rufus-scheduler'
require 'uri'
require 'net/http'
require 'openssl'
require 'json'
def getir
url = URI("https://koineks.com/ticker")
http = Net::HTTP.new(url.host, url.port)
@kobeumut
kobeumut / activeadmin_add_user_references_to_company.rb
Last active December 21, 2017 05:45
Ruby on rails add user references to company and display an email instead of an object in active admin
ActiveAdmin.register Company do
permit_params :user_id, :name ## Add this line
form do |f|
f.inputs "Admin Details" do
f.input :user_id, as: :select, collection: User.all.map { |a| [a.email, a.id] }
f.input :name
f.actions