Skip to content

Instantly share code, notes, and snippets.

View ofalvai's full-sized avatar

Olivér Falvai ofalvai

View GitHub Profile
@duncanbeevers
duncanbeevers / sc-dl-min.js
Created March 22, 2012 12:16 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(window){var i,$sound,$buttonGroup;var $sounds=$(".sound");var clientId=require("config").get("client_id");var oauthToken=require("lib/connect").getAuthToken();var conversionHelper=require("lib/helpers/conversion-helper");var $downloadButton,size;var params,downloadUrl,onSuccess;for(i=$sounds.length-1;i>=0;i--){$sound=$($sounds[i]);var soundcloudUrl="https://soundcloud.com"+($sound.find(".soundTitle__title").attr("href")||window.location.pathname);params={url:soundcloudUrl,client_id:clientId};onSuccess=function($sound){return function(data){var params={client_id:clientId};downloadUrl=require("lib/url").stringify({query:params},data.stream_url+".mp3");$buttonGroup=$($sound.find(".sound__soundActions .sc-button-group")[0]);size=$buttonGroup.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1];$downloadButton=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+conversionHelper.bytesToMB(data.origi
@ecampidoglio
ecampidoglio / cpustatus.sh
Created February 21, 2013 23:42
A Bash script that prints the current state of the CPU on a Raspberry Pi. It displays variables like temperature, voltage and speed.
#!/bin/bash
# cpustatus
#
# Prints the current state of the CPU like temperature, voltage and speed.
# The temperature is reported in degrees Celsius (C) while
# the CPU speed is calculated in megahertz (MHz).
function convert_to_MHz {
let value=$1/1000
echo "$value"
@davidensinger
davidensinger / summary-twitter-card-in-jekyll.html
Last active June 13, 2016 12:03
Support for the Summary Twitter Card in Jekyll
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@site_username">
<meta name="twitter:creator" content="@creator_username">
{% if page.title %}
<meta name="twitter:title" content="{{ page.title }}">
{% else %}
<meta name="twitter:title" content="{{ site.title }}">
{% endif %}
{% if page.url %}
<meta name="twitter:url" content="{{ site.url }}{{ page.url }}">
@ioguix
ioguix / 8.3 operator workaround.sql
Created June 2, 2014 15:28
Workaround using operators to implicit cast removed in PostgreSQL 8.3
CREATE FUNCTION pg_catalog.texteqint(text, integer) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(int4out($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqint2(text, smallint) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(int2out($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqoid(text, oid) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(oidout($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqdate(text, date) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(date_out($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqfloat8(text, double precision) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(float8out($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqreal(text, real) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(float4out($2)) = $1;$$;
CREATE FUNCTION pg_catalog.texteqtimetz(text, time WITH time zone) RETURNS BOOLEAN STRICT IMMUTABLE LANGUAGE SQL AS $$SELECT textin(timetz_out($2)) = $1;$$;
CREATE FUNCTION pg_cata
@bryanstern
bryanstern / OkHttpStack.java
Last active April 24, 2022 03:17
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21.
To use the support version of these attributes, remove the android namespace.
For instance, "android:colorControlNormal" becomes "colorControlNormal".
These attributes will be propagated to their corresponding attributes within the android namespace
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
import java.util.*
import kotlin.reflect.KProperty
/*
* Android Shared Preferences Delegate for Kotlin
*
* Usage:
@gklka
gklka / gist:c04abd41df4b9b0c3f6d24e9175bde9d
Created June 5, 2016 10:03
Ezt mentsétek el bookmarknak. A PizzaForte rendelési oldalon megnyomva a gombás pizzákat lehalványítja.
javascript:divs = $("div.product_info_panel p:contains('gomba')"); $.each(divs, function(index, value) { $(divs[index]).parent().parent().css('opacity', 0.3); });
@alphamu
alphamu / Android Privacy Policy Template
Created February 9, 2017 03:17
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@murki
murki / PlacesActivity.kt
Last active June 10, 2021 03:59
The poor man's Dagger: Exemplifying how to implement dependency injection on Android by (ab)using ApplicationContext's getSystemService(). Here we attain inversion of control without the need of any external library. We also use Kotlin's extension methods to provide a friendlier, strongly-typed API to locate dependencies.
class PlacesActivity : AppCompatActivity() {
private lateinit var placesPresenter: PlacesPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// This is how you instantiate your Presenter while the service locator resolves all of its dependencies
// Note that the explicit type argument <PlacesPresenter> is not even necessary since Kotlin can infer the type
placesPresenter = application.getSystemService<PlacesPresenter>()
}
}