Skip to content

Instantly share code, notes, and snippets.

View diamondobama's full-sized avatar
🎯
Focusing

Diamond diamondobama

🎯
Focusing
View GitHub Profile
@jas-
jas- / class.stream.php
Last active June 2, 2022 18:22
PHP stream handler w/ support for multiple files over PUT
<?php
/**
* stream - Handle raw input stream
*
* LICENSE: This source file is subject to version 3.01 of the GPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/licenses/gpl.html. If you did not receive a copy of
* the GPL License and are unable to obtain it through the web, please
*
@devmycloud
devmycloud / ParseInputStream.php
Last active December 6, 2023 15:22
Process php://input to get multipart/form-data parameters for PATCH API request
<?php
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* stream - Handle raw input stream
*
* LICENSE: This source file is subject to version 3.01 of the GPL license
* that is available through the world-wide-web at the following URI:
@JhonatanRaul
JhonatanRaul / HandlePutFormData.php
Last active March 8, 2023 12:58 — forked from iamntz/HandlePutFormData.php
Laravel: Middleware to support multipart/form-data in PUT, PATH and DELETE requests. Deals with one level of form arrays.
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\ParameterBag;
use Illuminate\Support\Arr;
/**
* @author https://github.com/Stunext
import com.google.firebase.*;
import com.google.firebase.iid.*;
import com.google.firebase.messaging.*;
FirebaseOptions.Builder builder = new FirebaseOptions.Builder()
.setApplicationId("<applicationId> i.e X:XXXXXXXXXX:android:XXXXXXXXXXXXXXXXXXXXX")
.setApiKey("<private key>")
.setDatabaseUrl("https://yourFcmApp.firebaseio.com")
.setStorageBucket("yourFcmApp.appspot.com");
FirebaseApp.initializeApp(context(), builder.build());
String token = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken();
if (token != null) {
com.codename1.io.Preferences.set("pushKey", token);
your.app.namespace.SomeClass.SomeStaticMethod(token); }
//check token is the same after 5 seconds
//cn1's gcm service sometimes gets the wrong token and this is then useful to overwrite it
java.util.Timer timer = new java.util.Timer();
timer.schedule(new java.util.TimerTask() {
public void run() {
package your.namespace;
import android.app.Activity;
import android.app.Application;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import com.codename1.impl.android.LifecycleListener;
import com.codename1.impl.android.AndroidNativeUtil;
import java.io.BufferedOutputStream;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.widget.Toast;
import android.content.Context;
import android.os.Bundle;
public class GroupsJobIntentService extends android.support.v4.app.JobIntentService {
/**
package com.groups;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
public class GroupsReceiver extends BroadcastReceiver {
@Override
import com.google.firebase.messaging.RemoteMessage;
import android.app.NotificationManager;
import android.app.Activity;
import android.content.Intent;
import android.app.PendingIntent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationCompat;
public String getPushIntent()
{
String actionId = null;
if (com.codename1.impl.android.AndroidNativeUtil.getActivity() != null){
Activity activity = com.codename1.impl.android.AndroidNativeUtil.getActivity();
android.os.Bundle extras = activity.getIntent().getExtras();
if (extras != null) {
actionId = extras.getString("pushAction");
extras.remove("pushAction");
activity.setIntent(new Intent());