This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set terminal pngcairo font "arial,8" size 640,350 | |
set output 'simple_distance.png' | |
set multiplot layout 1, 2 | |
r(d) = d*pi/180 | |
dist_hav(x,y,x0,y0) = 2*asin(sqrt(sin(r(y-y0)/2)**2 + cos(r(y0))*cos(r(y))*sin(r(x-x0)/2)**2))*6371 | |
dist_sim(x,y,x0,y0) = sqrt(r(y-y0)**2 + (cos(r(y0))*r(x-x0))**2)*6371 | |
error(x,y,x0,y0) = 100*abs(dist_hav(x,y,x0,y0)-dist_sim(x,y,x0,y0))/dist_hav(x,y,x0,y0) | |
set view map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function float2rat(x) { | |
var tolerance = 1.0E-6; | |
var h1=1; var h2=0; | |
var k1=0; var k2=1; | |
var b = x; | |
do { | |
var a = Math.floor(b); | |
var aux = h1; h1 = a*h1+h2; h2 = aux; | |
aux = k1; k1 = a*k1+k2; k2 = aux; | |
b = 1/(b-a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toUTF8Array(str) { | |
var utf8 = []; | |
for (var i=0; i < str.length; i++) { | |
var charcode = str.charCodeAt(i); | |
if (charcode < 0x80) utf8.push(charcode); | |
else if (charcode < 0x800) { | |
utf8.push(0xc0 | (charcode >> 6), | |
0x80 | (charcode & 0x3f)); | |
} | |
else if (charcode < 0xd800 || charcode >= 0xe000) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
CREATE FUNCTION maybe_utf8_decode(str text charset utf8) | |
RETURNS text CHARSET utf8 DETERMINISTIC | |
BEGIN | |
declare str_converted text charset utf8; | |
declare max_error_count int default @@max_error_count; | |
set @@max_error_count = 0; | |
set str_converted = convert(binary convert(str using latin1) using utf8); | |
set @@max_error_count = max_error_count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION STRINGDECODE(str TEXT CHARSET utf8) | |
RETURNS text CHARSET utf8 DETERMINISTIC | |
BEGIN | |
declare pos int; | |
declare escape char(6) charset utf8; | |
declare unescape char(3) charset utf8; | |
set pos = locate('\\u', str); | |
while pos > 0 do | |
set escape = substring(str, pos, 6); | |
set unescape = char(conv(substring(escape,3),16,10) using ucs2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.*; | |
class Test { | |
public static void main(String [] args) throws Exception { | |
Class.forName("com.mysql.jdbc.Driver"); | |
Connection conn = DriverManager.getConnection( | |
"jdbc:mysql://localhost/test?characterEncoding=utf8", "user", "pass"); | |
Statement s = conn.createStatement(); | |
s.execute("call hello('겠겠지만');"); | |
ResultSet rs = s.getResultSet(); | |
rs.next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$srcPath = "your source image path goes here"; | |
$dstPath = "your destination image path goes here"; | |
$size = "90x90"; | |
list($w, $h, $type) = getimagesize($srcPath); | |
switch ($type) { | |
case IMAGETYPE_JPEG: | |
$src = imagecreatefromjpeg($srcPath); |