Skip to content

Instantly share code, notes, and snippets.

View razvanioan's full-sized avatar

Razvan Ioan Anastasescu razvanioan

View GitHub Profile
@ryanpager
ryanpager / application-session-management-with-oauth.md
Last active July 26, 2020 22:54
Application Session Management With OAuth -- Ionic & AngularJS

Application Session Management With OAuth

Fun with AngularJS & Ionic

I don't know about other developers -- but one of the most frustrating things in my mind to get going when starting a new hybrid application is session/authorization management. Do you use OAuth 1, OAuth 2, generic email login, facebook...even thinking about it stresses me out. Unfortunately, no good hybrid (or mobile for that matter) application can escape the need for good authorization (unless it is a stateless app, like a calculator, or something easy).

Personally -- I have come to love the OAuth 2 standard for its simplicity, and standards of operation. It takes some of the stress out of the decision making process when coming up with how to manage application state flow -- something which is especially necessary in [most] mobile (or native) applications. This article is going to focus on one of those pain points -- hybrid mobile app state management, and how to solve it with regards to the marriage of AngularJS & Ion

@pazdera
pazdera / github-release.sh
Created October 17, 2018 17:06
Create a github release for an existing tag from the command line
#!/usr/bin/env bash
# https://developer.github.com/v3/repos/releases/#create-a-release
repo=$1
tag=$2
name=$3
text=$4
token=$GH_TOKEN
@generalredneck
generalredneck / xpath.php
Created September 27, 2012 18:12
XPath - A Fun Walk With A Powerful Query Language
<?php
require_once 'Console/Table.php';
$groupsDoc = new DOMDocument();
$groupsDoc->load("groups.xml");
$groupsDoc->formatOutput = TRUE;
file_put_contents("readable-groups.xml",$groupsDoc->saveXML());
$xpath = new DOMXpath($groupsDoc);
/*******************************************************************************
@molily
molily / filter.txt
Last active June 7, 2022 05:13
SVG filter: White drop shadow
<filter id="dropshadow" x="0" y="0" width="200%" height="200%">
<feColorMatrix in="SourceAlpha" type="matrix"
values="-1 0 0 0 1, 0 -1 0 0 1, 0 0 -1 0 1, 0 0 0 1 0"
result="matrix"/>
<feGaussianBlur in="matrix" stdDeviation="2" result="blur"/>
<feComposite in="SourceGraphic" in2="blur" operator="over"/>
</filter>
@dcpesses
dcpesses / photoreflect.js
Last active July 5, 2023 11:41
Re-enable right-click & add Download links to thumbnail pages on PhotoReflect pages.
/*
Copy the single line of code below, then add it as a new bookmark to your web browser of choice:
javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://gist.githubusercontent.com/dcpesses/9652778/raw';})();
Then browse to the thumbnails of the album, click on that bookmark, and...enjoy!
*/
document.oncontextmenu=document.body.oncontextmenu = new Function("return true");
@orottier
orottier / RetryTest.php
Last active July 21, 2023 10:10
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}
@orangexception
orangexception / gist:3941158
Created October 23, 2012 19:56
Regular Expression to Insert Character after every X Characters

Regular Expression to Insert Character after every X Characters

I had a simple problem today. I needed to validate some files, but all of the line breaks were missing. I was dealing with a fixed width format data. A quick regular expression later and I had readable data.

Here's a few examples to demo the idea.

Insert a line break after every 94 characters

Find (.{94}) Replace \1\n

Insert a comma after every 10 characters

@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@ColinMaudry
ColinMaudry / gist:6fd6a5f610f0ac3e6696
Last active November 24, 2023 15:46
cURL examples to query Wikidata

SPARQL Queries (with cURL command) on Wikidata

This gist resulted to be just the spark for a proper article, and won't be maintained here anymore.

The SPARQL endpoint is http://wdqs-beta.wmflabs.org/bigdata/namespace/wdq/sparql and it has a Web form to fire queries. However http://www.wikidata.org/prop/direct/P31 ("instance of") tells you what the entity is.

The repository doesn't have named graphs, or at least the SPARQL endpoint rejects graph queries. The classes of entities (rdf:type) are not described in the repository.

To find the HTML page of an entity (such as https://www.wikidata.org/entity/Q866405), simply replace /entity/ with /wiki/.

@cleverdevil
cleverdevil / markdown-to-email
Created January 4, 2014 01:06
markdown-to-email A simple script to send beautifully formatted emails that you write in Markdown. The email will have an HTML payload and a plain-text alternative, so you'll make everyone happy, including yourself.
#!/usr/bin/env python
'''
Send an multipart email with HTML and plain text alternatives. The message
should be constructed as a plain-text file of the following format:
From: Your Name <your@email.com>
To: Recipient One <recipient@to.com>
Subject: Your subject line
---