Skip to content

Instantly share code, notes, and snippets.

View loiclefloch's full-sized avatar

Loïc Lefloch loiclefloch

View GitHub Profile
@loiclefloch
loiclefloch / index.js
Last active May 10, 2020 15:11
Notion extension script - enhance notion
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.notion.so/*
// @grant none
// @require http://code.jquery.com/jquery-2.2.4.min.js
// ==/UserScript==
@loiclefloch
loiclefloch / proxy.php
Created August 2, 2016 09:04 — forked from iovar/proxy.php
Simple PHP Proxy Script
<?php
/*
* Warning! Read and use at your own risk!
*
* This tiny proxy script is completely transparent and it passes
* all requests and headers without any checking of any kind.
* The same happens with JSON data. They are simply forwarded.
*
* This is just an easy and convenient solution for the AJAX
@loiclefloch
loiclefloch / ApiManager.java
Created February 23, 2016 13:30
Android tools
import java.util.List;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.PUT;
import retrofit.http.Path;
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: 768px) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }
@loiclefloch
loiclefloch / BaseController.php
Last active November 5, 2015 23:01
Symfony REST API
<?php
namespace Example\ApiBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\View\View;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Validator\ConstraintViolation;
@loiclefloch
loiclefloch / Regex.swift
Created June 16, 2015 16:41
Simplify regex with Swift
import Foundation
infix operator =~ {}
func =~ (input: String, pattern: String) -> Bool {
return Regex(pattern).test(input)
}
class Regex {
let internalExpression: NSRegularExpression
@loiclefloch
loiclefloch / FormViewController.swift
Created June 11, 2015 12:58
iOS form next button handling.
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWasShown:", name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillBeHidden:", name: UIKeyboardWillHideNotification, object: nil)
}
override func viewWillDisappear(animated: Bool) {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
@loiclefloch
loiclefloch / String.swift
Last active December 7, 2015 03:38
Swift usefull extensions
extension String
{
var length: Int {
get {
return count(self)
}
}
func contains(s: String) -> Bool
{
@loiclefloch
loiclefloch / example.swift
Created June 8, 2015 13:06
Swift Keyboard handling
func viewDidLoad() {
super.viewDidLoad()
// Register to this notifications for handle reduction of the app
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("appWillResignActive"), name: UIApplicationWillResignActiveNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("appWillTerminate"), name: UIApplicationWillTerminateNotification, object: nil)
// Call end editing when the user tap on the screen but not in the keyboard or the text edit
var tapGesture = UITapGestureRecognizer(target: self, action: Selector("endEditing:"))
// prevents the scroll view from swallowing up the touch event of child buttons
@loiclefloch
loiclefloch / ViewController.swift
Created May 27, 2015 16:07
Horizontal Number Picker
class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {
@IBOutlet weak var dividerPickerViewContainer: UIView!
var dividerPickerView: UIPickerView = UIPickerView()
override func viewDidLoad() {
// dividerPicker
self.dividerPickerView.delegate = self
self.dividerPickerView.dataSource = self