Skip to content

Instantly share code, notes, and snippets.

@agershun
agershun / run.c
Created September 3, 2023 07:54
Fast llama.c version for Mac M1 Max 32 Gb. For Llama2_7b.bin the speed is 1 token per 3 seconds. Simply replace run.c and close all other programs.
/* Inference for Llama-2 Transformer model in pure C */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <fcntl.h>
#if defined _WIN32
@agershun
agershun / gist:dbf37cc5a9a71e0e3734867621c698b1
Created April 7, 2023 05:03
Rename group of files with mask in command line (BASH, ZSH, OSX, MAC)
# src - source file extension
# trg - target file extension
for i in *.src; do mv "$i" "${i/\.src/\.tgt}"; done
@agershun
agershun / Jnavi.java
Created September 12, 2018 04:50
Пример программы на языке Java, использующей Naviaddress API
import java.util.List;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import com.google.gson.Gson;
@agershun
agershun / main.lua
Created September 12, 2018 02:45
Пример использования Naviaddress API на языке Lua
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
-- Your code here
local json = require( "json" )
local cx = display.contentCenterX
@agershun
agershun / КодНавиадрес1С.txt
Created September 11, 2018 15:58
Пример программы на языке 1С, использующую Naviaddress API
&НаСервере
Процедура ПолучитьДанныеНавиадресаНаСервере()
Сервер = "staging-api.naviaddress.com";
Версия = "1.5";
Контейнер = "7";
Навиадрес = Объект.Навиадрес;
АдресРесурса = СтрШаблон("/api/v%1/Addresses/%2/%3", Версия, Контейнер, Навиадрес);
@agershun
agershun / index.html
Last active September 21, 2018 09:30
Пример простой программы, использующей Naviaddress API
<body>
<h1>Ближайший навиадрес</h1>
<p>Пример программы для получения информации о ближайшем объекте</p>
<div id="coords"></div>
<div id="naviaddress"></div>
<div id="postal"></div>
<div id="list"></div>
<script>
@agershun
agershun / gist:ff98dad115a4019115b6
Created October 14, 2015 04:47
Add video to HTML page
<video autoplay="" loop="" style="width: 100%; height: inherit; background: rgb(0, 0, 0);">
<source type="video/ogg" src="upload/BlocksPagesProperties/video_ogv/3ecdfc303ec3600045e0be1624e38ccd.ogv">
</video>
function copy(o) {
var out, v, key;
out = Array.isArray(o) ? [] : {};
for (key in o) {
v = o[key];
out[key] = (typeof v === "object") ? copy(v) : v;
}
return out;
}
@agershun
agershun / gist:3b1463cfcb9d3fb7b540
Created May 26, 2015 10:53
Remove comments from text for Jison
%lex
%option case-insensitive
%s mulcom onecom
%%
<<EOF>> return 'EOF'
<INITIAL>"/*" this.begin('mulcom'); return
<mulcom>"*/" this.popState(); return
@agershun
agershun / gist:3131ac94b6ad3c05e1d9
Created April 8, 2015 18:20
JavaScript class inherit() function
function inherit(child, parent) {
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = child;
child.prototype.super = function () {
parent.apply(this,arguments);
};
};
// How to use: