Skip to content

Instantly share code, notes, and snippets.

View Shaked's full-sized avatar

Shaked Klein Orbach Shaked

View GitHub Profile
@Shaked
Shaked / messenger-payload-location-image.php
Last active October 14, 2017 21:05
How to receive Messenger API location/image
<?php
if ($message->hasAttachments()) {
$attachments = $message->getAttachments();
$location = [];
foreach ($attachments as $attachment) {
switch($attachment['type']) {
case 'location':
$lat = $attachment['payload']['coordinates']['lat'];
$long = $attachment['payload']['coordinates']['long'];
@Shaked
Shaked / template-no-main-button.json
Created August 20, 2017 15:24
Messenger list template possible bug with Webview
[
{
"template_type": "list",
"elements": [
{
"title": "TEST - CHAIN",
"subtitle": "227 קל׳\n7 ג׳ חלבון\n10 שומן\n28 פחמ׳",
"image_url": "https://dummyimage.com/600x400/000/fff",
"buttons": null,
"default_action": {
// ==UserScript==
// @name Wikipedia English Translation
// @namespace https://wikipedia.org/*
// @version 0.0.4
// @downloadURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.user.js
// @updateURL https://gist.github.com/raw/bfc145808a639f85a02dfe03cd03cf60/WikipediaEnglishTranslation.meta.js
// @description Add the English term to the current term's title.
// @include https://*wikipedia.org/*
// @match https://*wikipedia.org/*
// @grant GM_setValue
@Shaked
Shaked / CurlMultiHandler.php
Last active September 8, 2016 11:58
Basic Guzzle Async Idea
<?php
namespace GuzzleHttp\Handler;
use GuzzleHttp\Promise as P;
use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Psr7;
use Psr\Http\Message\RequestInterface;
/**
* Returns an asynchronous response using curl_multi_* functions.
@Shaked
Shaked / kindle.meta.js
Last active June 27, 2022 22:56
Kindle Keywords Exporter
// ==UserScript==
// @name KindleKeywordsExporter
// @namespace https://kindle.amazon.com/your_highlights
// @version 0.0.8
// @downloadURL https://gist.github.com/raw/65e198dcda8784c557075b9b89265a16/kindle.user.js
// @updateURL https://gist.github.com/raw/65e198dcda8784c557075b9b89265a16/kindle.meta.js
// @description Helps exporting highlighted keywords from Kindle
// @include https://kindle.amazon.com/your_highlights
// @match https://kindle.amazon.com/your_highlights
// @grant GM_setValue
// ==UserScript==
// @name Sedarot - show video
// @namespace http://tampermonkey.net/
// @version 0.12
// @downloadURL https://gist.github.com/raw/84aef3ef6544f9efc92c25c6485e5a33/sratim.js
// @updateURL https://gist.github.com/raw/84aef3ef6544f9efc92c25c6485e5a33/sratim.meta.js
// @description try to take over the world!
// @author You
// @match http://www.sdarot.pm/watch/*
// @grant none
package com.rg.stash.plugin.commit.url.hook;
import com.atlassian.stash.hook.*;
import com.atlassian.stash.hook.repository.*;
import com.atlassian.stash.repository.*;
import java.util.Collection;
public class UrlCommitHook implements PreReceiveRepositoryHook {
/**
byte[] buffer = new byte[1024];
InputStream reader = new BufferedInputStream(is);
OutputStream writer = new BufferedOutputStream(os);
int read;
while ((read = reader.read(buffer)) != -1) {
writer.write(buffer, 0, read);
}
writer.flush();
writer.close();
<?php
# Copyright (c) 2015, phpfmt and its authors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
// Look for a certain process
def p = "ps -e".execute() | "grep java".execute() | "grep -v grep".execute()
p.waitFor()
// Show PID
println p.text.trim().split(" ")[0]