####PHP cheat sheet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/api/:id', function(req, res) { | |
var query = req.params.id.toLowerCase(); | |
knex.select('*').from('table').where('name', 'ilike', '%'+query+'%').limit(5).offset(30).orderBy('id', 'desc') | |
.then(function(rows){ | |
res.send(rows); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'app' | |
,'libs' | |
,'text!templates/review/review.tpl' | |
,'collections/tcidCollection' | |
], function(App, libs, review, TCIDCollection, undefined) { | |
//-- private ----------------------------------------------------------------------------------- | |
var $ = libs.$, _ = libs._, JSON = libs.JSON, Backbone = libs.Backbone, bootstrapValidator = libs.bootstrapValidator, Backgrid = window.Backgrid, tcidCollection, templateData, ReviewView, target, grid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO switch you fool, Switch! | |
alphaIndex: function(e){ | |
listings; | |
var arr = []; | |
var listName = listings.attributes.listings.items; | |
var listed = function(regex){ | |
_.each(listName, function(i){ | |
var string = i.name.substring(0, 1).match(regex); | |
if (i.name.substring(0, 1).match(regex) == i.name.substring(0, 1)){ | |
arr.push(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kurt's Swift guide. | |
import UIKit | |
// Variables | |
// 'var' will pick a type ie string or int or whatever | |
var make = "Ferrari" | |
var model = "488 GTB" | |
// Old concatenation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package somePackage | |
import org.springframework.security.core.GrantedAuthority | |
import org.springframework.security.core.userdetails.User | |
class LdapUser extends User{ | |
final String id | |
final String firstName | |
final String lastName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var display: UILabel! | |
var userIsInTheMiddleOfTypingANumber: Bool = false | |
@IBAction func appendDigit(sender: UIButton) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myContext = LAContext() | |
var authError: NSError? | |
// Set the reason string that will appear on the authentication alert. | |
var myReasonString = "String explaining why app needs authentication" | |
if myContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) { | |
[myContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: myReasonString, reply: { (success: Bool, evalPolicyError: NSError?) -> Void in | |
if success { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LAContext *myContext = [[LAContext alloc] init]; | |
NSError *authError = nil; | |
NSString *myReasonString = @"String explaining why app needs authentication"; | |
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { | |
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics | |
localizedReason:myReasonString | |
reply:^(BOOL succes, NSError *error) { | |
if (success) { | |
// User authenticated successfully |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodemailer = require('nodemailer'); | |
app.post('/mail', function(req, res) { | |
// Initial REST load | |
// create reusable transporter object using SMTP transport | |
var transporter = nodemailer.createTransport({ | |
service: 'Gmail', | |
auth: { | |
user: '<<username>>', | |
pass: '<<password>>' |