Skip to content

Instantly share code, notes, and snippets.

View upkarlidder's full-sized avatar
:octocat:
hiya!

Upkar Lidder upkarlidder

:octocat:
hiya!
View GitHub Profile
@upkarlidder
upkarlidder / gist:8536849
Created January 21, 2014 09:16
Check for internet connection
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
NSInteger responseCode = [(NSHTTPURLResponse *)response statusCode];
if (!connectionError && responseCode == 200){
// all is good, load the data
}
else{
//show error message
NSLog(@"connectionError=%@", connectionError);
NSLog(@"responseCode=%d", responseCode);
[SVProgressHUD showErrorWithStatus:@"Oops, unable to load movies, check your internet!"];
@upkarlidder
upkarlidder / SFTemperatureModel.h
Created January 21, 2014 09:21
Use enum in Objective-C
#import <Foundation/Foundation.h>
enum TEMPERATURE_TYPE{
CELCIUS,
FAHRENHEIT,
};
@interface SFTemperatureModel : NSObject
@upkarlidder
upkarlidder / wee2-quiz2
Created September 19, 2016 23:12
Machine learning quiz 2 - multiple regression code
# coding: utf-8
# # Regression Week 2: Multiple Regression (gradient descent)
# In the first notebook we explored multiple regression using graphlab create. Now we will use graphlab along with numpy to solve for the regression weights with gradient descent.
#
# In this notebook we will cover estimating multiple regression weights via gradient descent. You will:
# * Add a constant column of 1's to a graphlab SFrame to account for the intercept
# * Convert an SFrame into a Numpy array
[
{
"id": "b93671f5.98624",
"type": "debug",
"z": "5d7690ec.49781",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 579.5,
@upkarlidder
upkarlidder / gist:204ce29ab4f1a43c0205489decee337e
Last active September 26, 2016 23:42
coursera-iot-assignment2
[
{
"id": "dc765e4b.46713",
"type": "subflow",
"name": "random",
"info": "",
"in": [
{
"x": 230,
"y": 320,
From https://zemian.github.io/2016/10/05/My-Quick-Git-Reference.html
git clone http://path/to/repo.git # Retrieve a repo for work (auto checkout master branch into WorkingDir)
git init # Create new repository for work (auto checkout master branch into WorkingDir)
git init --bare # Create new repository without WorkingDir - bare repo for server share only
git status # Print current status of the repo
git branch -a # List of all branches (including remote branches)
git tag # List of all tags
git log -3 # Show last 3 commits
//TRY 1
// const nextCharForNumberString = function(str){
// const trimmed = str.trim();
// const number = parseInt(trimmed);
// const nextNumber = number + 1;
// return String.fromCharCode(nextNumber);
// }
//TRY 2
// const nextCharForNumberString = function(str){
@Test
public void getAllBooksShouldReturnListOfAllBooks() throws Exception {
final String expectedTitle = "The Lightning Thief";
mockMvc.perform(get(baseUrl + getAllBooksURL)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(5)))
public static Matcher<List<Book>> containsTitle(final String title){
return new BaseMatcher<List<Book>>() {
@Override
public boolean matches(Object item) {
List<Book> books = (List<Book>) item;
List<Book> booksFiltered = books.stream()
.filter(b -> b.getTitle().equalsIgnoreCase(title))
.collect(Collectors.toList());
return !booksFiltered.isEmpty();
}
@upkarlidder
upkarlidder / quesadilla.bash
Created February 23, 2017 19:27 — forked from captainsafia/quesadilla.bash
When the user has changed into a git directory, rebase with upstream if there are no uncommitted files.
function cd {
# Run the system CD command on the parameters that were passed in
builtin cd "$@"
# Check if the directory we are in now is a git directory
if [ -d ".git" ]; then
# If so, check to see that there are no uncommitted files
if [ $(git status --porcelain 2>/dev/null| egrep "^(M| M)" | wc -l) ]; then
# Rebase our current branch with upstream/master
git fetch upstream && git rebase upstream/master
fi