Skip to content

Instantly share code, notes, and snippets.

View ilyasKerbal's full-sized avatar

ILYAS KERBAL ilyasKerbal

View GitHub Profile
@marioluan
marioluan / connection.php
Created January 21, 2013 22:14
Simple web application I've coded to insert, delete and select data from database using PHP and MySQL. I've also made both client and server-side validation. Check out a live demo at http://www.marioluan.com.br/php/.
<?php
// openning connection
$link = mysqli_connect('host', 'user', 'password', 'database')
or die('Could not connect to server'.'<br>');
// uncomment next line to debug
//print 'connection opened'.'<br>';
?>
@Antarix
Antarix / horizontal_progress_demo.xml
Last active February 16, 2022 08:54
Android Custom horizontal ProgressBar emample
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progress_limit"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@jawinn
jawinn / Fit Layer To Canvas.jsx
Created September 30, 2015 15:38
Fit Layer To Canvas - Photoshop Script
// FIT LAYER TO CANVAS
// via https://forums.adobe.com/message/5413957#5413957
var maintainAspectRatio;// set to true to keep aspect ratio
if(app.documents.length>0){
app.activeDocument.suspendHistory ('Fit Layer to Canvas', 'FitLayerToCanvas('+maintainAspectRatio+')');
}
function FitLayerToCanvas( keepAspect ){// keepAspect:Boolean - optional. Default to false
var doc = app.activeDocument;
var layer = doc.activeLayer;
// do nothing if layer is background or locked
@mbejda
mbejda / Industries.csv
Last active July 1, 2024 10:49
Compiled list of industries.
Industry
Accounting
Airlines/Aviation
Alternative Dispute Resolution
Alternative Medicine
Animation
Apparel/Fashion
Architecture/Planning
Arts/Crafts
Automotive
@lopspower
lopspower / README.md
Last active January 19, 2024 10:54
What's difference between -nodpi and -anydpi?

Difference between -nodpi and -anydpi

Android Studio exposes developers to -nodpi and -anydpi in various places. For example, if you use the New Resource Directory wizard thing, and you choose to add a density qualifier to the directory, you will see "No Density" (-nodpi) and "Any Density" (-anydpi) options.

Some of you might expect these to be well-documented.

In a word, no.

However, courtesy of a fair amount of experimentation (largely done as part of work on this Stack Overflow question and this answer), their use becomes at least a bit clearer. Many thanks to Stack Overflow user rds for the help!

@gtomek
gtomek / arcCanvas.java
Last active April 20, 2022 02:16
How to draw a rounded arc on canvas Android
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(50);
// Setting the color of the circle
mPaint.setColor(Color.BLUE);
// Draw the circle at (x,y) with radius 250
@valyala
valyala / README.md
Last active June 3, 2024 17:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@michaelkeevildown
michaelkeevildown / credit-card-regex.md
Last active June 12, 2024 07:20
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$
@handstandsam
handstandsam / SSLHandshakeInterceptor.java
Created April 7, 2017 17:57
OkHttp 3 SSL Handshake Interceptor - Prints TLS Version & Cipher Suite Used
import android.util.Log;
import java.io.IOException;
import okhttp3.CipherSuite;
import okhttp3.Handshake;
import okhttp3.Response;
import okhttp3.TlsVersion;
/** Prints TLS Version and Cipher Suite for SSL Calls through OkHttp3 */
public class SSLHandshakeInterceptor implements okhttp3.Interceptor {
@einichi
einichi / getIP.gs
Created December 25, 2019 07:50
Get IP Address of Hostname - Google App Script
function getIP(host, recordType) {
// Specify record type as per described here: https://en.wikipedia.org/wiki/List_of_DNS_record_types
// For example, 'A', 'AAAA', 'NS', etc...
// So your Google Sheets formula would be =getIP("www.example.com", "A")
var url = "https://dns.google.com/resolve?name=" + host + "&type=" + recordType;
var json = UrlFetchApp.fetch(url);
var response = JSON.parse(json);
var answer = response.Answer;
var ip = "";
if (typeof answer != "undefined") {