Skip to content

Instantly share code, notes, and snippets.

@mdeora
mdeora / RecyclerViewExt.kt
Created April 23, 2019 15:53 — forked from ricknout/RecyclerViewExt.kt
Change order of args to enable trailing lambda syntax
package com.nickrout.snaphelperlistener
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
fun RecyclerView.attachSnapHelperWithListener(
snapHelper: SnapHelper,
behavior: SnapOnScrollListener.Behavior = SnapOnScrollListener.Behavior.NOTIFY_ON_SCROLL,
onSnapPositionChangeListener: OnSnapPositionChangeListener) {
snapHelper.attachToRecyclerView(this)
@mdeora
mdeora / styles.xml
Created March 27, 2019 11:44 — forked from mustafasevgi/styles.xml
Android appcompat full screen and hide status bar
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
@mdeora
mdeora / classifier.php
Created May 14, 2018 12:56 — forked from andreiz/classifier.php
A simple example of logistic regression via gradient descent in PHP.
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@mdeora
mdeora / classifier.php
Created May 14, 2018 12:56 — forked from andreiz/classifier.php
A simple example of logistic regression via gradient descent in PHP.
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@mdeora
mdeora / classifier.php
Created May 14, 2018 12:56 — forked from andreiz/classifier.php
A simple example of logistic regression via gradient descent in PHP.
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@mdeora
mdeora / strpos_array.php
Created December 28, 2017 15:10 — forked from msng/strpos_array.php
PHP: strpos_array is strpos that can take an array as needle
<?php
function strpos_array($haystack, $needles, $offset = 0) {
if (is_array($needles)) {
foreach ($needles as $needle) {
$pos = strpos_array($haystack, $needle);
if ($pos !== false) {
return $pos;
}
}
return false;
@mdeora
mdeora / strpos_array.php
Created December 28, 2017 15:10 — forked from msng/strpos_array.php
PHP: strpos_array is strpos that can take an array as needle
<?php
function strpos_array($haystack, $needles, $offset = 0) {
if (is_array($needles)) {
foreach ($needles as $needle) {
$pos = strpos_array($haystack, $needle);
if ($pos !== false) {
return $pos;
}
}
return false;
@mdeora
mdeora / RunAProxyOnAmazonEC2VPC.md
Created August 12, 2017 10:12 — forked from webinista/RunAProxyOnAmazonEC2VPC.md
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
@mdeora
mdeora / mysql_tuning_parameters
Created January 5, 2017 12:18 — forked from muresan/mysql_tuning_parameters
MySQL tunning from a persentation
All the changes that are fit to print. Droppin’ Mo’ Science 52 All Your IOPS Are Belong To Us: Ernie Souhrada, Database Engineer @ Pinterest - Percona Live MySQL Conference & Expo 2015 Full list of customizations / changes deployed:
-  Linux kernel 3.18.7
-  irqbalance 1.0.8
-  RPS enabled
-  Jemalloc instead of Glibc
-  Disk IO scheduler = noop
-  XFS + 64K RAID block size
-  Mount options: -  noatime,nobarrier,discard,inode64,logbsize=256k
-  my.cnf changes:
innodb_max_dirty_pages_pct = 75
@mdeora
mdeora / nginx.conf
Created September 17, 2016 12:53 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048