Skip to content

Instantly share code, notes, and snippets.

View furkantektas's full-sized avatar

Furkan Tektas furkantektas

View GitHub Profile
@furkantektas
furkantektas / AndroidManifest.xml
Created June 22, 2014 00:12
Logs Cell info to the sdcard and shares them via e-mail
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tr.edu.gyte.android.cellinfogsm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
@furkantektas
furkantektas / DatePickerFragment.java
Last active February 11, 2020 20:52
Android DatePicker without year field.
public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
final int year = c.get(Calendar.YEAR);
final int month = c.get(Calendar.MONTH);
final int day = c.get(Calendar.DAY_OF_MONTH);
@furkantektas
furkantektas / point_model.php
Last active August 29, 2015 14:04
Point Accessors for Eloquent (Laravel)
<?php
class ModelName extends Eloquent {
// Ref: http://stackoverflow.com/a/23750526
// Assuming Point is entered as text. Eg: 41,29
public function setLocationAttribute($value) {
$loc = explode(',',$value);
$this->attributes['location'] = DB::raw("ST_GeomFromText('POINT(".$loc[0]." ".$loc[1].")', 4326)");
}
@furkantektas
furkantektas / PointValidator.php
Created September 12, 2014 14:30
Yii location validator. Sample Location: 41 29
<?php
/**
* PointValidator class for Yii.
* Author: Furkan Tektas github.com/furkantektas
* Date: 2014/09/05
* Version: v1.0
*/
class PointValidator extends CValidator
{
@furkantektas
furkantektas / PointValidator.php
Created September 12, 2014 14:35
PostGIS GeoJSON validator for Yii. Place these files under application/protected/components/
<?php
require_once('SpatialGeoJSONValidator.php');
/**
* PointValidator class for Yii.
* Author: Furkan Tektas github.com/furkantektas
* Date: 2014/09/12
* Version: v1.0
* Sample GeoJSON: {"type":"Point","coordinates":[41.00603847483829,29.009458422660828],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}
*/
class PointValidator extends SpatialGeoJSONValidator {
@furkantektas
furkantektas / AspectRatioCardView.java
Created November 16, 2014 11:48
CardView with aspect ratio
package com.furkantektas.braingames.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import com.furkantektas.braingames.R;
/**
@furkantektas
furkantektas / CountDownTimerWidget.java
Created November 20, 2014 23:00
Custom CountDownTimer Widget for Android
package com.furkantektas.braingames.ui;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.CountDownTimer;
import android.util.AttributeSet;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Date;
@furkantektas
furkantektas / get_relevant_many_to_many.sql
Created December 23, 2014 16:52
Get relevant items for many to many relation
# Reference : http://stackoverflow.com/a/7227944/1360267
SELECT
t1.*,
count(DISTINCT r2.relation2) as relevance
FROM pivot_table r1
INNER JOIN pivot_table r2 ON (r1.relation2 = r2.relation2
AND r1.relation1 <> r2.relation1)
INNER JOIN table1 t1 ON (r2.relation1 = t1.id)
WHERE r1.relation1 = '14' -- this is the id results should be related to.
GROUP BY t1.id
@furkantektas
furkantektas / slicer.sh
Created December 9, 2015 19:48
Test and training data generator
#!/bin/sh
# This script creates a seperate training and test datasets
# using data*.log file. wsize is the window size, i.e. how
# many lines will be gathered from each data*.log file.
# This script creates 20 seperate test & training files
wsize=100
filelen=9999
for i in $(find . -name 'data*.log'); do
templen=$(wc -l < $i)
@furkantektas
furkantektas / batch-classiffier.sh
Last active December 10, 2015 04:26
Batch classification for Weka 3.7+
#!/bin/sh
# This script assumes that the working directory contains 20 training and test arff files
# with prefix training- and test-, respectively. It trains a model using RotationForest (with
# default parameters) and saves the statistical data to results-n.arff where n is the number of
# trainig file.
# Then it prints out the correctly classified instances information to all-results.txt
for i in {1..20}; do