Skip to content

Instantly share code, notes, and snippets.

View bahaddinyasar's full-sized avatar

Bahaddin Yaşar bahaddinyasar

  • San Francisco
View GitHub Profile
@bahaddinyasar
bahaddinyasar / font.css
Last active December 10, 2015 09:38
font style that I like
*
{
font-family:'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight:normal;
font-style: normal;
color: #333333;
text-align: justify;
}
@bahaddinyasar
bahaddinyasar / box_sizing_border_box_ftw.css
Created December 19, 2012 14:38
Paul Irish box-sizing-border-box-ftw
/* http://paulirish.com/2012/box-sizing-border-box-ftw/ */
/* apply a natural box layout model to all elements */
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@bahaddinyasar
bahaddinyasar / php_localization_gettext.php
Created December 11, 2012 13:48
Php Localization - gettext
<?php
//ref: http://php.net/manual/en/function.gettext.php
// Set language to German
putenv('LC_ALL=de_DE');
setlocale(LC_ALL, 'de_DE');
// Specify location of translation tables
bindtextdomain("myPHPApp", "./locale");
@bahaddinyasar
bahaddinyasar / javascript_singleton_pattern.js
Created October 24, 2012 08:43
Javascript Singleton Pattern
// instantiate the singleton only when it's needed, put it's instantiation code inside another constructor function like this:
var Singleton =(function(){
var instantiated;
function init (){
// all singleton code goes here
return {
publicWhatever:function(){
alert('whatever')
},
@bahaddinyasar
bahaddinyasar / javascript_facade_pattern.js
Created October 24, 2012 06:55
Javascript Facade Pattern
//The following are facades for jQuery's $.ajax():
$.get( url, data, callback, dataType );
$.post( url, data, callback, dataType );
$.getJSON( url, data, callback );
$.getScript( url, callback );
//These are translated behind the scenes to:
// $.get()
$.ajax({
@bahaddinyasar
bahaddinyasar / javascript_string_literal_vs_string_object.js
Created October 18, 2012 14:43
javascript string literal vs string object
var s_prim = "foo";
var s_obj = new String(s_prim);
console.log(typeof s_prim); // Logs "string"
console.log(typeof s_obj); // Logs "object"
//----------------
s1 = "2 + 2"; // creates a string primitive
s2 = new String("2 + 2"); // creates a String object
@bahaddinyasar
bahaddinyasar / encodeURI_vs_encodeURIComponent.txt
Created October 5, 2012 13:13
encodeURI() vs encodeURIComponent()
encodeURI()
Use encodeURI when you want a working URL.
Ex:
encodeURI("http://www.google.com/a file with spaces.html"); // produces http://www.google.com/a%20file%20with%20spaces.html
Note: Don't call encodeURIComponent since it would destroy the URL and return
http%3A%2F%2Fwww.google.com%2Fa%20file%20with%20spaces.html
@bahaddinyasar
bahaddinyasar / how_to_put_a_checkbox_in_a_uitableviewcell.m
Created October 5, 2012 08:55
How to put a checkbox in a UITableViewCell
- (void)tableView:(UITableView *)theTableView
didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath {
[theTableView deselectRowAtIndexPath:[theTableView indexPathForSelectedRow] animated:NO];
UITableViewCell *cell = [theTableView cellForRowAtIndexPath:newIndexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
// Reflect selection in data model
} else if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
@bahaddinyasar
bahaddinyasar / checking_for_icloud_availability.m
Created October 5, 2012 07:10
Checking for iCloud Availability
// in the AppDelegate.m, add the following code to the method application:didFinishLaunchingWithOptions
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
NSLog(@"iCloud access at %@", ubiq);
// TODO: Load document...
} else {
NSLog(@"No iCloud access");
}
@bahaddinyasar
bahaddinyasar / angularjs_and_jqueryui_slider_binding.html
Created September 24, 2012 13:46
AngularJS and jQueryUI slider binding
<html ng-app="myApp">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script type="text/javascript" ng:autobind src="http://code.angularjs.org/1.0.2/angular.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/redmond/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
function MyController() {
this.years = "1950";