Skip to content

Instantly share code, notes, and snippets.

View selfup's full-sized avatar
💻
doing the most

Regis Boudinot selfup

💻
doing the most
View GitHub Profile
localStorage.setItem('wow', "hello")
localStorage.getItem('wow')
console.log('ok')
alert('WOW')

Best practice for installing rust

Here is the link to the rustup website

Here are the docs for rustup

Follow these steps:

  1. curl https://sh.rustup.rs -sSf | sh (This is now the official rust version manager!)

Playground for Lspi

Open up the console and start playing around!

(F12) on Windows - (Cmd + Option + i) on Mac - (F12) on Linux.

Then click the console tab.

Try the following:

lspi.createRecord("testOne")
// Now that you have created a record try grabbing it
lspi.getRecord("testOne")
// This returns an empty object. Now we add a real object
lspi.updateRecord("testOne", {test: "Basic data for the 'testOne' record"})

Simple Aliases

Step 1

alias batman="sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y"
alias gs="git status"
alias ga="git add ."
alias gc="git commit -m"
alias gp="git pull"
extern crate rustc_serialize;
extern crate stringer;
use rustc_serialize::json::{self};
use std::collections::HashMap;
use std::ffi::CString;
use std::os::raw::c_char;
use stringer::*;
#[no_mangle]
class RustPoro
extend FFI::Library
@ffi_lib_path = BinaryPath.new.rust_binary
ffi_lib @ffi_lib_path
attach_function :read_json, [:string], :string
end
extern crate rustc_serialize;
use rustc_serialize::json::{self};
use std::collections::HashMap;
use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char;
#[no_mangle]
pub extern fn read_json(ro: *const c_char) -> *const c_char {
#[no_mangle]
pub extern fn read_json(ro: *const c_char) -> *const c_char {
let roo = make_string(ro);
let json_for_rust: HashMap<String, i32> = json::decode(&roo).unwrap();
let encoded = json::encode(&json_for_rust).unwrap();
let concated_string = CString::new(encoded).unwrap();
concated_string.into_raw()
}
fn make_string(s1: *const c_char) -> String {
RUST_BACKTRACE=1 cargo build
Compiling rust v0.1.0 (file:///Users/RJPB2/Documents/rustedrails/bin/embedded/rust)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/Users/RJPB2/.multirust/toolchains/nightly/lib/rustlib/x86_64-apple-darwin/lib" "/Users/RJPB2/Documents/rustedrails/bin/embedded/rust/target/debug/nth_prime.0.o" "-o" "/Users/RJPB2/Documents/rustedrails/bin/embedded/rust/target/debug/libnth_prime.dylib" "/Users/RJPB2/Documents/rustedrails/bin/embedded/rust/target/debug/nth_prime.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/RJPB2/Documents/rustedrails/bin/embedded/rust/target/debug" "-L" "/Users/RJPB2/Documents/rustedrails/bin/embedded/rust/target/debug/deps" "-L" "/Users/RJPB2/.rbenv/versions/2.3.0/lib" "-L" "/Users/RJPB2/.multirust/toolchains/nightly/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-force_load,/var/folders/db/31c017ks01x4sgzbfzzrvl780000gn/T/rustc.8QXOubNLwv5f/libruru-90b63cc301e85c86.rlib" "-Wl,-force_load,/var/folders/db/31c017ks01x4sgzbfzzrvl780000