Skip to content

Instantly share code, notes, and snippets.

💻
Coding... coding.. coding.... and coding..!

Hendi Santika hendisantika

Block or report user

Report or block hendisantika

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hendisantika
hendisantika / StringCompare.md
Created May 7, 2019 — forked from Yengas/StringCompare.md
Java String comparison, differences between ==, equals, matches, compareTo
View StringCompare.md

String Comparison

In this gist, i will try to explain you what is the main differences between known string comparison techniques and where to use them.

Explanation of methods

==

This is the main equality operator in Java. To summarize it, this method compares the left and right hands references to eachother and returns boolean. This means this operator returns true only if left and right variable both point at the same Object in the memory. As in most of the class comparisons, this operators is discouraged to use if you're not really intented to check if two variables point to same object.

View docker-machine-mac-osx.md

VirtualBox

  • https://www.docker.com/toolbox
  • docker-machine create --driver virtualbox dev
  • docker-machine env dev (add values to ~/.zshrc)
    • e.g. echo eval "$(docker-machine env dev)" >> ~/.zshrc
  • docker-machine ls
  • docker ps (might need to re-source .zshrc file; e.g. . ~/.zshrc)
  • docker run hello-world
  • docker-machine ip dev
@hendisantika
hendisantika / postgres-cheatsheet.md
Created Feb 28, 2019 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
View JavaLoopII.java
class Solution{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
int sum=0;
for(int j=1;j<=n;j++)
View hill_and_vally.py
def hill_and_vally(s):
d=[x1-x0 for x0,x1 in zip(s,s[1:]) if x1!=x0]
return 2+sum(d0*d1<0 for d0,d1 in zip(d,d[1:]))
#>>> hill_and_vally([1,0,0,0,1])
#3
#>>> hill_and_vally([0,1,0,1,0])
#5
#>>> hill_and_vally([0,2,2,1,1,0,0])
#3
View countHillNValley.java
public class Solution {
public int countHillNValley(int[] nums) {
if(nums == null || nums.length == 0)
return 0;
if(nums.length == 1)
return 1;
int count = 1;
int i = 0, j = i + 1;
while(i < nums.length && j < nums.length){
if(nums[j] == nums[i]){
View FindDuplicate.java
package com.hendisantika.test.tes3;
import java.util.HashMap;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* Project : test-java
* User: hendisantika
* Email: hendisantika@gmail.com
@hendisantika
hendisantika / index.html
Created Nov 4, 2018
Real Time Javascript Calculation Based On Form Inputs
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Tes Form</title>
</head>
<body>
<input id='first' type="text" class="form-control formBlock" name="bus_ticket" placeholder="Bus Ticket..." required/><br />
<input id='second' type="text" class="form-control formBlock" name="plane_ticket" placeholder="Plane Ticket..." required/><br />
@hendisantika
hendisantika / MySQL_macOS_Sierra.md
Created May 14, 2018 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew
View MySQL_macOS_Sierra.md

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@hendisantika
hendisantika / bank.xml
Created Apr 5, 2018
Some XSD examples (and reminders!)
View bank.xml
<?xml version="1.0" encoding="UTF-8"?>
<bank xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="bank.xsd">
<accounts>
<savings_accounts>
<savings_account id="a1" interest="0.03">
<balance>2500</balance>
</savings_account>
<savings_account id="a2" interest="0.03">
<balance>15075</balance>
</savings_account>
You can’t perform that action at this time.