Skip to content

Instantly share code, notes, and snippets.

View mcatta's full-sized avatar
📚
Learning

Marco Cattaneo mcatta

📚
Learning
View GitHub Profile
@mcatta
mcatta / ShareCount.php
Created May 20, 2014 07:34
Contatore di condivisioni (FB, Twitter, Google Plus) data la url della pagina
<?php
class ShareCount {
/**
* Ritorno conteggio condivisioni facebook
* @param [String] $url url articolo
* @return [Integer] conteggio
*/
public static function get_fb_share($url) {
@mcatta
mcatta / DataArray.php
Created May 22, 2014 15:23
Create php array year/month/day based on start epochtime to end epochtime
<?php
class DataArray {
private static $start;
private static $end;
/**
* Costructor, start date end date in epochtime
* @param [type] $start [description]
@mcatta
mcatta / check.js
Created June 17, 2014 12:41
Check resolution via jquery + CSS (Bootstrap)
$( function() {
if( $('.sm-visible').is(':visible') ) {
console.log('is tablet');
/**
* code
**/
}
if( $('.xs-visible').is(':visible') ) {
console.log('is smartphone');
/**
<?php // encoding: utf-8
/*Copyright 2008Qian Qin(email : mail@qianqin.de)
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 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@mcatta
mcatta / CURLtoShop.php
Created July 1, 2014 08:02
CURL php with arguments: url post data
class CURLtoShop {
/**
* CURL in POST
* @param [type] $url url della chiamata
* @param [type] $posts campi post
* @return [type] [description]
*/
public static function post($url, $posts) {
@mcatta
mcatta / progress_bar.xml
Created August 28, 2014 11:00
ProgressBar style XML
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="@color/progress_blue"
android:centerColor="@color/progress_blue"
android:centerY="0.75"
@mcatta
mcatta / search.php
Created September 3, 2014 16:32
Search Text into string PHP
if (stripos($text, "world") !== false) {
echo "True";
}
@mcatta
mcatta / convert.java
Created October 23, 2014 15:24
GSON library String to obj, obj to String
Gson gson = new Gson();
// Obj -> JSON String
ObjectClass object = new ObjectCLass();
String jsonString = gson.toJson(object);
// JSON String -> Obj
Type listType = new TypeToken<ObjectClass>(){}.getType();
ObjectClass object = gson.fromJson(jsonString, listType);
@mcatta
mcatta / fragdialogback.java
Created December 3, 2014 13:09
Prevent close DialogFragment on backpress
// Prevent close on backpress
dialog.setOnKeyListener( new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK)
return true;
else
return false;
}
});
@mcatta
mcatta / MyFragment.java
Created February 9, 2015 18:40
Remove fragment from backstack
/**
* Created by marcocattaneo on 21/01/15.
*/
public class MyFragment extends Fragment {
public static MyFragment newInstance() {
MyFragment frag = new MyFragment();
return frag;
}