Skip to content

Instantly share code, notes, and snippets.

View afbora's full-sized avatar
🎯
Focusing

Ahmet Bora afbora

🎯
Focusing
View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active August 16, 2024 17:36
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@eusonlito
eusonlito / foldersize.php
Last active March 11, 2025 07:56
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
@bastianallgeier
bastianallgeier / controllers--contact.php
Created October 1, 2014 19:36
Plain contactform example for Kirby 2
<?php
return function($site, $pages, $page) {
$alert = null;
if(get('submit')) {
$data = array(
'name' => get('name'),
@fomightez
fomightez / remove blank lines regex.md
Last active March 10, 2025 15:35
remove all blank lines using regular expressions
@mandiwise
mandiwise / Update remote repo
Last active April 27, 2025 11:53
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@bastianallgeier
bastianallgeier / mywidget.php
Created March 9, 2015 10:54
Most basic widget setup for panel widgets. You would put those two files in /site/widgets/mywidget/
<?php
return array(
'title' => 'Widget Title',
'html' => function() {
// any data for the template
$data = array();
return tpl::load(__DIR__ . DS . 'template.php', $data);
}
);
@paulochf
paulochf / countries.sql
Last active April 26, 2024 09:50 — forked from adhipg/countries.sql
Outdated. Used with discretion. Accepting updates.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
<img src="<?php $page->image()->crop(300, 200)->url() ?>" alt="Cropped by width and height">
<img src="<?php $page->image()->crop(300)->url() ?>" alt="Cropped box">
<img src="<?php $page->image()->resize(300, 200)->url() ?>" alt="Resized by width and height">
<img src="<?php $page->image()->resize(300)->url() ?>" alt="Resized by width only">
<img src="<?php $page->image()->resize(false, 200)->url() ?>" alt="Resized by height only">
@flokosiol
flokosiol / getkirby-panel-save-button-fixed.css
Last active September 8, 2020 09:52
Fixes the Kirby (getkirby.com) panel topbar and the save button at the top of the browser window.
/*
Fixes the Kirby (getkirby.com) panel topbar and the save button at the top of the browser window.
Put this css snippet in your assets/css/panel.css file and add the following to your site/config/config.php
c::set('panel.stylesheet', 'assets/css/panel.css');
@see: http://forum.getkirby.com/t/move-the-save-button/1867/11?u=flokosiol
*/
.topbar {
position: fixed;