Skip to content

Instantly share code, notes, and snippets.

@avafloww
avafloww / PhpJava.java
Last active June 13, 2024 07:36
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@ibrahimlawal
ibrahimlawal / TLSSocketFactory.java
Last active November 11, 2018 21:53 — forked from fkrauthan/TLSSocketFactory.java
**A fork** Custom SSLSocketFactory Implementation to enable tls 1.2 for android 4.1 (16+) - modified to get system default TrustManagers and for use with retrofit 2 and okHttp 3.1.2;
package co.paystack.android.api.utils;
/**
* Created by ibrahimlawal on Mar/14/2016.
*
* @author fkrauthan
* @see http://blog.dev-area.net/2015/08/13/android-4-1-enable-tls-1-1-and-tls-1-2/
* @since 1.2.0
*
* Modified to work with okHttp3.1.2
@MatthewSteeples
MatthewSteeples / mousemove.ps1
Created February 26, 2015 19:09
Powershell Script to keep the mouse moving
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
$x = ($pos.X % 500) + 1
$y = ($pos.Y % 500) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
Start-Sleep -Seconds 10
}
@tartakynov
tartakynov / fourex.py
Last active July 15, 2024 16:24
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
@yong27
yong27 / apply_df_by_multiprocessing.py
Last active April 12, 2023 04:35
pandas DataFrame apply multiprocessing
import multiprocessing
import pandas as pd
import numpy as np
def _apply_df(args):
df, func, kwargs = args
return df.apply(func, **kwargs)
def apply_by_multiprocessing(df, func, **kwargs):
workers = kwargs.pop('workers')
// Make it Nasty
function increment (i) {
i ^= (i & ~-~i) | (~i & -~i)
return i
}
@perrygeo
perrygeo / normalize_numpy.py
Created January 11, 2013 17:10
Normalize a 2D numpy array so that each "column" is on the same scale (Linear stretch from lowest value = 0 to highest value = 100)
import numpy as np
rawpoints = np.array(
[[2500, 0.15, 12],
[1200, 0.65, 20],
[6200, 0.35, 19]]
)
# Scale the rawpoints array so that each "column" is
# normalized to the same scale
@dergachev
dergachev / README.md
Created October 10, 2012 16:49
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static