Skip to content

Instantly share code, notes, and snippets.

View arturmkrtchyan's full-sized avatar

Artur Mkrtchyan arturmkrtchyan

View GitHub Profile
@arturmkrtchyan
arturmkrtchyan / AssemblyMain.java
Last active August 29, 2015 14:08
JIT: Run Java With PrintAssembly
public class AssemblyMain {
public static void main(String[] args) {
int number = 100000;
System.out.println("Calculating SUM of the squares of 1 to " + number);
long sum = sum(number);
System.out.println("SUM: " + sum);
}
@arturmkrtchyan
arturmkrtchyan / FunctionalPrime.java
Last active August 29, 2015 14:08
Functional vs. Imperative Programming
public boolean isPrime(final int number) {
return number > 1 &&
IntStream.rangeClosed(2, (int) Math.sqrt(number))
.noneMatch(index -> number % index == 0);
}
@arturmkrtchyan
arturmkrtchyan / build_jdk_9.sh
Last active August 29, 2015 14:10
Building OpenJDK 9 on Ubuntu
bash ./configure
make all
@arturmkrtchyan
arturmkrtchyan / BiasedLocking.java
Last active August 29, 2015 14:12
Uncontended Biased Locking
public class BiasedLocking {
private static final int LOOP_COUNT = 10000000; // 10 million
public static void main(final String[] args) {
incrementCounter();
}
public static void incrementCounter() {
final long startTime = System.currentTimeMillis();
@arturmkrtchyan
arturmkrtchyan / EnumSwitch.class
Last active August 29, 2015 14:13
JVM tableswitch vs lookupswitch
private static void enumSwitch();
Code:
0: getstatic #2 // Field DayOfWeek.FRIDAY:LDayOfWeek;
3: astore_0
4: iconst_0
5: istore_1
6: getstatic #3 // Field Switch$1.$SwitchMap$DayOfWeek:[I
9: aload_0
10: invokevirtual #4 // Method DayOfWeek.ordinal:()I
13: iaload
@arturmkrtchyan
arturmkrtchyan / thread1.c
Last active August 29, 2015 14:14
POSIX pthreads
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
void *thread_function(void *arg) {
int i;
for ( i=0; i<20; i++ ) {
printf("Thread says hi!\n");
sleep(1);
}
@arturmkrtchyan
arturmkrtchyan / add_slaves.sh
Last active August 29, 2015 14:16
Hadoop Cluster Installation
10.64.200.48
10.64.200.49
10.64.200.50
10.64.200.51
@arturmkrtchyan
arturmkrtchyan / Intro.md
Last active October 13, 2016 16:27
Machine Learning Introduction

Machine Learning Algorithm families

Supervised Learning (e.g. classification, anomaly detection, regression)

  • Input data is called training data and has a known label or result such as spam/not-spam or a stock price at a time.
  • A model is prepared through a training process where it is required to make predictions and is corrected when those predictions are wrong. The training process continues until the model achieves a desired level of accuracy on the training data.
  • Example problems are classification and regression.
  • Example algorithms include Logistic Regression and the Back Propagation Neural Network.

Unsupervised Learning (e.g. clustering and dimensionality reduction)

  • Input data is not labelled and does not have a known result.
import jdk.incubator.http.*;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("http://www.google.com")).GET().build();
HttpResponse response = client.send(request, HttpResponse.BodyHandler.asString())
System.out.println(response.body())
@arturmkrtchyan
arturmkrtchyan / softr_add_user_email_and_record_id_to_form.html
Created February 19, 2021 18:10
Softr Add User Email and RecordID to a Form
<script>
document.addEventListener("DOMContentLoaded", function () {
const emailFieldName = 'Email';
const jobIdFieldName = 'JobID';
const formId = 'submitreferral';
const userEmail = getUserEmail();
const recordId = getUrlParam('recordId');