Skip to content

Instantly share code, notes, and snippets.

View ozgun's full-sized avatar

Ozgun Koyun ozgun

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / bytecode_to_java_code.java
Created January 22, 2014 10:07
Bytecode to java code
/*
* Bytecode:
* * public tr.gov.tubitak.uekae.esya.api.asn.cms.ECompleteCertificateReferences getCompleteCertificateReferences() throws tr.gov.tubitak.uekae.esya.api.common.ESYAException;
* 0 aload_0 [this]
* 1 new com.objsys.asn1j.runtime.Asn1ObjectIdentifier [52]
* 4 dup
* 5 getstatic tr.gov.tubitak.uekae.esya.asn.cms._etsi101733Values.id_aa_ets_certificateRefs : int[] [64]
* 8 invokespecial com.objsys.asn1j.runtime.Asn1ObjectIdentifier(int[]) [54]
* 11 invokevirtual tr.gov.tubitak.uekae.esya.api.asn.cms.ESignerInfo.getUnsignedAttribute(com.objsys.asn1j.runtime.Asn1ObjectIdentifier) : java.util.List [55]
* 14 astore_1
@ozgun
ozgun / folding.java
Created February 10, 2014 13:23
IntelliJ IDEA folding example
public void init() {
//Execute a job on the event-dispatching thread; creating this applet's GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
buffer = new StringBuffer();
}
});
} catch (Exception e) {
@ozgun
ozgun / build.xml
Created February 19, 2014 09:37
Japa Applet'i için ant build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Smartcard Login Applet" default="sign">
<!-- MANIFEST.MF dosyasındaki Application-Name alanının değeri -->
<property name="app.name" value="Smartcard Login Applet" />
<!-- Name of the output .jar file -->
<property name="jar.name" value="yh-smartcard-login.jar" />
<!-- Main class -->