Skip to content

Instantly share code, notes, and snippets.

Avatar

Kubilay Erdogan kublaios

View GitHub Profile
View SendSelectedPhotoWithEmailViewController.swift
import UIKit
import _Concurrency
class SendSelectedPhotoWithEmailViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// self.startFlow_PoD()
self.startFlow_AsyncAwait()
}
@kublaios
kublaios / mail.php
Last active Aug 29, 2015
Sample PHPMailer Script with Gmail Settings
View mail.php
<?php
function sendMailerMail($recipient, $subject, $email_content)
{
// include phpmailer class and initialize
require_once __dir__ . 'class.phpmailer.php';
$mail = new PHPMailer();
// //
// set up mail server settings
// sample for gmail
View gist:0609617440a10d393904
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
@kublaios
kublaios / user_templates.py
Last active Aug 29, 2015
Sublime Text PHP Getters and Setters Plugin Tiny Template
View user_templates.py
class camelCaseTiny(object):
name = "camelCaseTiny"
style = 'camelCase' # can also be snakeCase
getter = """
public function get%(normalizedName)s() { return $this->%(name)s; }"""
setter = """
public function set%(normalizedName)s(%(typeHint)s $%(name)s) { $this->%(name)s = $%(name)s; }"""
@kublaios
kublaios / pdo_duplicate_key_update.php
Created Jul 12, 2014
PDO ON DUPLICATE KEY UPDATE for multiple insert rows
View pdo_duplicate_key_update.php
function test() {
$sql = "INSERT INTO `table` (`id`, `name`) VALUES (?,?),(?,?) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`) ";
$values = array(1, "test", 2, "so so");
$stmt = $this->db->prepare($sql);
$stmt->execute($values);
}
@kublaios
kublaios / record_objects.php
Created Jul 12, 2014
Sample record function for using PDO's rollback transaction funcs.
View record_objects.php
<?php
/**
* Sample record function for using PDO's rollback transaction funcs.<br />
* <b>By: </b>Kubilay Erdogan
* @param array $objects Object objects array (each object must be created)
* @return array Result array
*/
public function recordObjects($objects = array()) {
if (count($objects) == 0) { $objects = $this->objects; } // set fields to self property if empty
if (count($objects) == 0) return true; // if still empty, then return.
@kublaios
kublaios / git.sh
Created Jul 10, 2014
Shell script to add, commit and push changes in a single line of code
View git.sh
git add -A;
git commit -m "$1";
git push origin $2
@kublaios
kublaios / gist:226dbea44105dd9b1c60
Created Jul 1, 2014
Sample iOS Game Sharing High Score With UIActivityViewController
View gist:226dbea44105dd9b1c60
- (void)share:(NSNotification *)notification {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);
[self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// high score stuff
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"score"]) {
@kublaios
kublaios / gist:f01cdf4369c86ddd6d71
Created Jun 27, 2014
Making a PEM File for iOS Push Notifications (From Ray Wenderlich's tutorial)
View gist:f01cdf4369c86ddd6d71
# Convert the .cer file into a .pem file:
$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
# Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -in PushChatKey.p12 -out PushChatKey.pem
# Finally, combine the certificate and key into a single .pem file
$ cat PushChatCert.pem PushChatKey.pem > ck.pem
# At this point it’s a good idea to test whether the certificate works.
@kublaios
kublaios / .gitignore
Created Jun 26, 2014
Sample .gitignore for Xcode 4 & 5 Projects
View .gitignore
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
*.DS_Store
*.lock
*.mode1v3
*.mode2v3
*.moved-aside
*.o