Skip to content

Instantly share code, notes, and snippets.

View ozgun's full-sized avatar

Ozgun Koyun ozgun

View GitHub Profile
@ozgun
ozgun / create.rb
Created January 16, 2014 08:22
json response example (API)
def create
respond_to do |format|
resp = { }
resp_status = :unprocessable_entity # 422
if (user = OtpAuth::UserAuthenticator.authenticate(params[:email].to_s, params[:password].to_s))
if (profile = OtpAuth::Profile.first_or_create(user_id: user.id))
device = profile.devices.build(push_service_type_id: OtpAuth.get_service_provider_id(params[:push_service_type].to_s.upcase),
@ozgun
ozgun / mimeapps.list
Created December 31, 2013 13:25
User: ~/.local/share/applications/mimeapps.list System: /usr/share/applications/defaults.list Bu dosyadaki xxxx.desktop şeklindeki ifadenin "xxxx"in /usr/share/applications/xxxx.desktop şeklinde bir dosyası olması lazım.
[Added Associations]
x-scheme-handler/http=exo-web-browser.desktop
x-scheme-handler/https=exo-web-browser.desktop
image/jpeg=gthumb.desktop;
x-scheme-handler/file=exo-file-manager.desktop
x-scheme-handler/trash=exo-file-manager.desktop
x-scheme-handler/mailto=exo-mail-reader.desktop
application/javascript=gvim.desktop;
text/plain=gvim.desktop;
application/x-wine-extension-inf=gvim.desktop;
@ozgun
ozgun / AppConfig.java
Created December 27, 2013 14:53
Parse settings.xml
package com.example;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Element;
@ozgun
ozgun / inter-vpos.txt
Created November 29, 2013 14:46
$ openssl s_client -connect inter-vpos.com.tr:443 -showcerts -status < /dev/null
depth=0 C = TR, ST = Istanbul, L = Istanbul, O = DENIZBANK A.S., OU = DENIZBANK A.S., OU = Terms of use at www.verisign.com/rpa (c)05, CN = inter-vpos.com.tr
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = TR, ST = Istanbul, L = Istanbul, O = DENIZBANK A.S., OU = DENIZBANK A.S., OU = Terms of use at www.verisign.com/rpa (c)05, CN = inter-vpos.com.tr
verify error:num=27:certificate not trusted
verify return:1
depth=0 C = TR, ST = Istanbul, L = Istanbul, O = DENIZBANK A.S., OU = DENIZBANK A.S., OU = Terms of use at www.verisign.com/rpa (c)05, CN = inter-vpos.com.tr
verify error:num=21:unable to verify the first certificate
verify return:1
CONNECTED(00000003)
@ozgun
ozgun / 20120913125411_change_store_settings_to_longtext.rb
Created November 27, 2013 08:42
Rails migration: text to longtext (MySQL)
class ChangeStoreSettingsToLongtext < ActiveRecord::Migration
def up
change_column :site_configs, :store_settings, :longtext
end
def down
change_column :site_configs, :store_settings, :text
end
end
@ozgun
ozgun / change_medium_to_mediumtext.rb
Last active December 29, 2015 12:48
Change text field to mediumtext field
change_column :post_translations, :field_name, :text, :limit => 64.kilobytes + 1
@ozgun
ozgun / hotp_plus_totp.rb
Last active December 29, 2015 10:39
Generating One-Time Password using both HOTP and TOTP
# encoding: utf-8
require 'openssl'
require "base64"
# https://github.com/mdp/rotp
require 'rotp'
def truncate_hmac(hmac, padded=true)
@ozgun
ozgun / gist:7089225
Created October 21, 2013 19:09
ActionMailer settings
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:port => 587,
:address => "mx.yandex.net",
:user_name => "test@example.com",
:password => "12345",
:domain => "example.com",
:authentication => :plain
}
@ozgun
ozgun / save_css_xhr
Created September 6, 2013 12:20
save_css_xhr
def save_css_xhr
file = @s_site.css_file(:write => true)
file.write(params[:code])
file.close
respond_to do |format|
format.js { }
end
end
test vim gist