Skip to content

Instantly share code, notes, and snippets.

View achudars's full-sized avatar
🥔
every challenge is an opportunity

Aleks achudars

🥔
every challenge is an opportunity
View GitHub Profile
@achudars
achudars / user.json
Created November 21, 2013 14:09
My SublimeText 3 configuration
PLUGINS:
Package Control
Theme - Soda
AngularJS
GitGutter
LESS
Monokai Extended
SideBarEnhancements
SublimeLint
@achudars
achudars / OneMax.py
Created November 5, 2013 10:37
Weak Hill Climbing
#[Q1] Weak hill climbing, OneMax
import random
from random import randrange
# returns a modified array with one bit flipped
def randomBitFlip(array):
random_index = randrange(0,len(array))
random_bit = array[random_index]
if random_bit == 0:
@achudars
achudars / gist:7254435
Created October 31, 2013 18:21
'matlabs' в терминале - запустить MatLab
help
; - не выводить o/p
clear - очистить все переменные
(1:5) - интервал от 1 до 5 [1 2 3 4 5]
(1:2:7) - и. от 1 до 7 с шагом в 2 [1 3 5 7]
linspace(A,B) - от A до B с одинаковым шагом Матрицы
A=[1 2] - одномерная матрица
A=[1 1; 2 2] - ; в обьявлении матрицы добавляет измерение
B=B * 2 - умножить каждый элемент на 2
@achudars
achudars / sample.bat
Created October 31, 2013 16:19
Batch script for Windows to launch Mongoose tiny server and open up the browser
@echo off
rem 1
start http://127.0.0.1:8080/
rem 2
cd C:\Documents and Settings\user\Desktop
start mongoose-3.1.exe
exit
@achudars
achudars / Vagrant steps.md
Last active December 26, 2015 16:49
Vagrant for Windows 8.1
  1. Install Git for Windows; Install Oracle VirtualBox.

  2. Install Vagrant and restart your PC.

  3. Run Git Bash and cd to preferred directory. Then:

vagrant init trusty32 http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box
@achudars
achudars / web-snippet-056 (AngularJS http get data.json)
Last active December 21, 2015 19:29
AngularJS - usage of $http and getting data from an external file
'use strict';
/* Controllers */
var app = angular.module('myApp.controllers', []);
app.controller('MyCtrl1', ['$scope', '$http', function($scope, as) {
as({method: 'GET', url: 'data/data.json'}).
success(function(data, status, headers, config) {
@achudars
achudars / web-snippet-055 ( upload to Imgur in JavaScript)
Created August 12, 2013 08:31
Use JavaScript to upload anonymously to Imgur using Imgur API and show the link to the file. Make sure your API key is valid and working!
function upload(file) {
var imageLink ="";
/* Is the file an image? */
if (!file || !file.type.match(/image.*/)) return;
var fd = new FormData();
fd.append("image", file); // Append the file
fd.append("key", "<Imgur API key>");
@achudars
achudars / web-snippet-054 ( Wunderground API Temperature example )
Created August 12, 2013 08:28
Sample usage of Wunderground Weather API with AJAX and JSONP. Gets current temperature in Celsius degrees in London, UK
jQuery.ajax({
url : "http://api.wunderground.com/api/<your key here>/geolookup/conditions/q/UK/London.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_c = parsed_json['current_observation']['temp_c'];
console.log(location + " at "+ temp_c);
// jQuery('#temperature').html(temp_c+"&deg;");
}
@achudars
achudars / web-snippet-053 ( Capture Right Mouse Click with JavaScript )
Created August 12, 2013 08:24
Capture Right Mouse Click with JavaScript
<div oncontextmenu="javascript:alert('success!'); return false;">
Lorem Ipsum
</div>
@achudars
achudars / web-snippet-052 ( preprocessJSON )
Last active December 19, 2015 12:39
Converts JavaScript strings into proper JSON without the usage of eval(). This is an awesome function found here: http://stackoverflow.com/questions/4781226/convert-converted-object-string-to-json-or-object/4781447#4781447
function preprocessJSON(str) {
return str.replace(/("(\\.|[^"])*"|'(\\.|[^'])*')|(\w+)\s*:/g,
function(all, string, strDouble, strSingle, jsonLabel) {
if (jsonLabel) {
return '"' + jsonLabel + '": ';
}
return all;
});