Skip to content

Instantly share code, notes, and snippets.

@egulhan
egulhan / function.is-json-encoded.php
Created April 14, 2015 09:16
Determine if string is json encoded or not using PHP
<?php
function isJsonEncoded($str)
{
json_decode($str);
return json_last_error() == JSON_ERROR_NONE ? true : false;
}
?>
@maolivn
maolivn / url_slug.php
Last active August 29, 2015 14:25 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@sooop
sooop / e051.py
Last active August 29, 2015 14:27
Project Euler on Python(3) #005 (051~060)
"""두 자리 숫자 *3의 첫번째 자리를 여러가지로 바꿨을 때 가능한 아홉 가지의 결과 중에서 13, 23, 43, 53, 73, 83의 여섯 개는 소수입니다.
56**3 의 3번째와 4번째 자리를 동일한 숫자로 바꿔서 만들어지는 10개의 다섯자리 숫자 중에서는 아래에서 보듯이 7개가 소수가 되며, 이것은 이런 식으로 7개의 소수가 만들어지는 첫번째 경우입니다. 이 소수 집단의 첫번째 수인 56003은 이런 성질을 갖는 가장 작은 소수입니다.
56003, 56113, 56333, 56443, 56663, 56773, 56993
위의 예처럼 원래의 일부를 동일한 숫자로 치환했을 때 8개의 소수 집단이 만들어지는 경우를 찾고, 그 집단에 속한 가장 작은 소수를 구하세요.
치환하는 자리는 인접하지 않아도 되고, 가장 앞부분을 치환하는 경우 거기에 0은 올 수 없습니다."""
@mikespook
mikespook / gist:3003825
Created June 27, 2012 12:36
检测图片内容是否匹配
<?php
// 获得图片的采样
function samplingGif($filename) {
$sampling = array();
$img = imagecreatefromgif($filename);
$size = getimagesize($filename);
$w = $size[0];
$h = $size[1];
for($x = 0; $x < $w; $x++) {
$sampling[$x] = array();
@wgm89
wgm89 / simpleimage.php
Created November 30, 2012 03:52 — forked from miguelfrmn/simpleimage.php
SimpleImage PHP Class
<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@solos
solos / offline_evernote.py
Created February 23, 2013 07:03
Offline evernote on android - solos's or diaosi's way to evernote pro.
#!/usr/bin/python
#coding=utf-8
import sqlite3
import os
from lxml import etree
def get_notes(ever_enex):
'''extract notes from .enex file'''
content = open(ever_enex, 'r').read()
@squarism
squarism / nginx.sh
Created August 20, 2012 03:33
Ubuntu 12.04 Nginx init.d script
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@sumardi
sumardi / gist:3936651
Created October 23, 2012 04:26
Laravel nginx config
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com;
index index.php;
@sean-hill
sean-hill / Ionic and ngCordova upload example
Last active May 6, 2019 01:52
Upload service for Ionic and ngCordova
Ionic and ngCordova upload example
@ryandotsmith
ryandotsmith / a-backbone-js-demo-app-sinatra-backend.md
Created January 22, 2012 01:42
Backbone demo app with sinatra backend

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].