Skip to content

Instantly share code, notes, and snippets.

View cupnoodle's full-sized avatar

soulchild cupnoodle

View GitHub Profile
@cupnoodle
cupnoodle / LetsEncryptCertbotNginx.sh
Created January 28, 2018 10:27
Lets Encrypt Certbot SSL installer for Nginx
sudo certbot --authenticator standalone --installer nginx -d <domain name> -d <domain name> --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
@cupnoodle
cupnoodle / ViewController.m
Created September 12, 2017 06:57
Left to right mask animation for UIImageView
- (IBAction)animateTapped:(id)sender {
[self animateMask:maskLayer forImageView:self.tailsImage];
}
- (void)animateMask:(CAShapeLayer *)mask forImageView:(UIImageView *)image{
// https://stackoverflow.com/questions/11391058/simply-mask-a-uiview-with-a-rectangle
if(image == nil){
@cupnoodle
cupnoodle / customURLSchemeQueryParams.m
Created June 21, 2017 03:03
Get query parameter of custom URL Scheme for iOS application
// upush://view?subject=moral&files=lect1.docx
-(void)openLink:(NSURL *)url {
NSString *host = [url host];
//param=value
NSString *query = [url query];
NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
NSArray *queryItems = [components queryItems];
@cupnoodle
cupnoodle / tictactoe.rb
Last active April 10, 2017 15:21
Tic Tac Toe Winning Check with O(1) time
@boardsize = 0
@boards_map = Array.new(1) {Array.new(1,"·")}
positionArray = Array.new
# keep track of how many X in a given row
@row_stats = Array.new
# keep track of how many X in a give column
@column_stats = Array.new
@cupnoodle
cupnoodle / UIViewController+Utils.m
Created December 7, 2016 08:26
Get the current active view controller on iOS screen
//
// UIViewController+Utils.m
// Novel
//
// Created by Axel Kee on 07/12/2016.
// Copyright © 2016 Javed. All rights reserved.
//
#import "UIViewController+Utils.h"
@cupnoodle
cupnoodle / sites-available-ghost
Created October 22, 2016 18:48
Ghost nginx config file with HTTPS Remember to put the well-known location in default file
server {
listen 80;
server_name fluffy.es;
#location / {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $http_host;
# proxy_pass http://127.0.0.1:2368;
#}
#location ~ /.well-known {
@cupnoodle
cupnoodle / titleAnimateViewController.swift
Created October 20, 2016 09:08
Animate titleLabel in UIButton
//
// ViewController.swift
// Animated Button
//
// Created by Soul on 20/10/2016.
// Copyright © 2016 sweatshops. All rights reserved.
//
import UIKit
@cupnoodle
cupnoodle / preventhotlink.json
Created October 1, 2016 09:47
Prevent hotlink bucket policy
@cupnoodle
cupnoodle / scp-applicationyml.txt
Last active September 19, 2016 21:22
copy application.yml using scp from local to remote server
scp -P port_number_here config/application.yml username@remote_server_ip:/home/username/app_name/config/application.yml
@cupnoodle
cupnoodle / add-git-remote.txt
Created September 9, 2016 15:01
Add git remote
git remote add live ssh://username@your_server_ip:port/home/username/repo/app_name.git