Skip to content

Instantly share code, notes, and snippets.

package com.example.utils;
import android.annotation.SuppressLint;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
@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 / copydb_all_tables_mysqli.php
Last active June 1, 2018 20:07
Copy all tables from one database to another database using php code
<?php
$dblink1=mysqli_connect('[server ip1]', '[username]', '[password]'); // connect server 1
mysqli_select_db($dblink1,'[db name]'); // select database 1
$dblink2=mysqli_connect('[server ip2]', '[username]', '[password]'); // connect server 2
mysqli_select_db($dblink2,'[db name]'); // select database 2
$tables = mysqli_fetch_array(mysqli_query($dblink1,"SHOW TABLES "));
@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.