Skip to content

Instantly share code, notes, and snippets.

View egulhan's full-sized avatar
Here we go again...

Erman Gülhan egulhan

Here we go again...
View GitHub Profile
@egulhan
egulhan / js-object-with-dynamic-key.js
Created August 27, 2014 14:19
How to create javascript object with dynamic key
var
k1='key1',
k2='key2',
obj={};
obj[k1]='dynamic key val 1';
obj[k2]='dynamic key val 2';
// writes "dynamic key val 1"
write(obj.key1);
@egulhan
egulhan / change-hostname-on-centos.sh
Created September 2, 2014 06:57
How to change hostname on centos
$ vim /etc/sysconfig/network
HOSTNAME={NEW_HOSTNAME}
$ vim /etc/hosts
127.0.0.1 {NEW_HOSTNAME}
$ hostname {NEW_HOSTNAME}
$ /etc/init.d/network restart
@egulhan
egulhan / remove-item-from-array.js
Created September 22, 2014 14:04
How-to remove Item from Array
// Remove Item from Array
$(document).ready(function(){
var arr = ["jQuery","JavaScript","HTML","Ajax","Css"];
var itemtoRemove = "HTML";
arr.splice($.inArray(itemtoRemove, arr),1);
});​
@egulhan
egulhan / get-query-str-variable.js
Last active August 29, 2015 14:07
How to get query string parameters using javascript
// example url='ex.com/index.php?name=heyhey'
// get name param. from query string
var name=getQueryVariable('name');
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
@egulhan
egulhan / get-route.php
Created October 25, 2014 14:38
How to get current route info in Yii application
$controllerId=Yii::app()->controller->id;
$actionId=Yii::app()->controller->action->id;
@egulhan
egulhan / example.html
Created November 5, 2014 14:58
How to load css by ajax
<script type="text/javascript">
var cssFiles=['css/custom/modal.css','css/custom/modal2.css'];
getCss(cssFiles,baseUrl);
</script>
@egulhan
egulhan / designer.html
Created November 18, 2014 08:31
designer
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
<template>
<style>
@egulhan
egulhan / controller.php
Last active October 28, 2015 20:52
How to populate a dropDownList after a dropDownList changed in Yii
<?php
//...
public function actionGetRouteStopsByRouteId()
{
$p=$_POST;
$routeId=null;
foreach ($p as $param) {
if(!empty($param['routeId']))
@egulhan
egulhan / algorithm-question.php
Created December 2, 2014 13:25
Solution for an algorithm question using PHP
<?php
/*
QUESTION
--------
Verify if the given password is valid/invalid;
1. must be 5-12 characters long
2. must contain atleast one number and one lowercase character
3. a sequence must not be followed by the same sequence (like 123123qs is invalid, 123qs123 is valid)
*/
@egulhan
egulhan / yii-activeform-error-css-class.php
Created December 12, 2014 13:17
How to set error css classes in Yii ActiveForm manually
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
'inputContainer'=>'.form-group',
'errorCssClass'=>'has-error',
),
'errorMessageCssClass'=>'help-block',
)); ?>