Skip to content

Instantly share code, notes, and snippets.

byte[] IFD_Address_tmp = Arrays.copyOfRange(bytes, 4, 8);
int IFD_Address = 0;
int i = 0;
int shiftBy = 0;
for (shiftBy = 0; shiftBy < 32; shiftBy += 8) {
IFD_Address |= ((long) (IFD_Address_tmp[i] & 0xff)) << shiftBy;
i++;
}
@codepedia
codepedia / ddl
Last active January 24, 2019 16:49
$ cat $_
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
//Your dynamic content
var catImage = "http://n-z.tv/wp-content/uploads/2017/08/cat-1024x683.jpg";
var message = "Hey this is some dynamic content";
var title = "Some Dynamic Content"
//Create the string and insert it into the body (or the "template" for you)
document.body.innerHTML = `
<div>
<h3>${title}</h3>
<img src="${catImage}"/>
@codepedia
codepedia / pagina.html
Created February 10, 2017 05:43 — forked from vquaiato/pagina.html
submetendo um form para o google spreadsheet sem redirect
<script type="text/javascript">
var submitted = false;
function submit(){
if(submitted) {
alert('Obrigado por cadastrar seu e-mail!');
document.getElementById('entry_0').value = '';
}
</script>
<iframe name="hidden_iframe" id="hidden_iframe" style="display: none;" onload="submit();"></iframe>
@codepedia
codepedia / vim
Last active November 3, 2019 17:56
:%s/<Ctrl-V><Ctrl-M>//g
find spaces before end of line and remove it ..anything before this "$"
:%s/\s\+$//g
#ctrlP plugin
:h ctrlp-mapping
#repeat a char
@codepedia
codepedia / sql
Last active March 15, 2017 17:38
# find the diff between two tables.
( SELECT * FROM table1
EXCEPT
SELECT * FROM table2)
UNION ALL
( SELECT * FROM table2
EXCEPT
SELECT * FROM table1)
=====
[root@dev-instance ~]# adduser zee
[root@dev-instance ~]# su - zee
[sudo] password for zee:
[root@dev-instance ~]# passwd zee
Changing password for user zee.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@dev-instance ~]# vim /etc/passwd
# if you want to install gems locally , without having to use sudo
uhc:blazer-dev zatef$ bundle install --path vendor/bundle
# when push rails app to a brand new ubuntu machine, I came across multiple bugs and had to fix them with the below:
# even though we have 2.3, we still need the dev version.
sudo apt-get install ruby2.3-dev
sudo apt-get install build-essential
# returns back what was changed after gitting pull locally.
git diff HEAD^^ HEAD nmae/of/thefile.rb
FYI ,
# this will show what was last added your local "showing newly added changes"
git diff --color HEAD^ HEAD
# this will do the reverse .. it will show the commit prior to pulling from the remote.
git diff --color HEAD HEAD^
Print keys and values from hash
The \A and \Z are just like "^" and "$"
my @keys;
while (<>) {
chomp; # Or: s/\s+\z//;
push @keys, $_;
}