Skip to content

Instantly share code, notes, and snippets.

@vlapenkov
vlapenkov / MemoryCacheManager.cs
Created December 21, 2018 12:09
MemoryCacheManager
public class MemoryCacheManager
{
#region Fields
private readonly IMemoryCache _cache;
/// <summary>
/// All keys of cache
/// </summary>
/// <remarks>Dictionary value indicating whether a key still exists in cache</remarks>
@roninhack
roninhack / proxy.py
Created November 24, 2018 15:25 — forked from scturtle/proxy.py
use opera's built-in VPN as proxy
#!/usr/bin/env python3
import asyncio
from vpn import get_proxy
proxy = port = auth = None
pool = asyncio.Queue(5)
psize = 0
async def process_client(client_reader, client_writer, *, CHUNK=4096):
global psize
@Shelob9
Shelob9 / caldera-button.css
Last active August 29, 2017 19:09
CSS for changing Caldera Forms buttons (including submit button) color, width or centering the button. https://calderaforms.com/doc/button/
/** Center the button (inside it's column) **/
.caldera-grid .btn {
display: block !important;
margin-left: auto;
margin-right: auto;
}
/** Make button the full width of the column **/
.caldera-grid .btn {
width:100%
@andhie
andhie / PermissionUtil.java
Last active October 23, 2017 17:04
Marshmallow Permission Level
public static void printPermissions(Context context) {
PackageInfo android;
try {
android = context.getPackageManager().getPackageInfo("android", PackageManager.GET_PERMISSIONS);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return;
}
PermissionInfo[] permissions = android.permissions;
@DanDiplo
DanDiplo / JS-LINQ.js
Last active October 14, 2025 22:02
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
/**
* Template Redirect
* Use page_beaver.php for all static Pages.
*/
add_filter( 'template_include', 'custom_page_template', 99 );
function custom_page_template( $template ) {
if ( is_singular( 'page' ) ) {
$new_template = locate_template( array( 'page_beaver.php' ) );
if ( '' != $new_template ) {
@imran0101
imran0101 / EndlessRecyclerOnScrollListener.java
Last active February 22, 2022 12:50
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
@About2git
About2git / functions.php
Last active January 21, 2019 07:14 — forked from srikat/functions.php
Full width Soliloquy slider with Header floating on the top in Genesis
//* Register Home Slider widget area
genesis_register_sidebar( array(
'id' => 'home-slider',
'name' => __( 'Home Slider', 'mpp' ),
'description' => __( 'This is the home slider widget area.', 'mpp' ),
) );
//* Add custom Slider + Header wrapper's opening div tag
add_action( 'genesis_before_header', 'sk_home_opening_div' );
function sk_home_opening_div() {
@About2git
About2git / archive-books.php
Last active November 17, 2020 18:12 — forked from srikat/archive-books.php
Single and Archive templates for Custom Post Type in Genesis
<?php
//* Remove breadcrumbs
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
//* Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove entry meta in entry header
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;