Skip to content

Instantly share code, notes, and snippets.

View bepcyc's full-sized avatar
🙃
Sparkling

Viacheslav Rodionov bepcyc

🙃
Sparkling
  • Qualcomm
  • Germany
View GitHub Profile
@bepcyc
bepcyc / apt.conf
Created January 19, 2012 15:02
Proxy for apt in Debian/Ubuntu
#define in apt.conf
Acquire {
Retries "0";
HTTP {
Proxy "http://username:password@proxy.mystarhub.com.sg:8080";
};
};
@bepcyc
bepcyc / FreeBitmapMemory.java
Created January 30, 2012 12:28
The way to free Bitmap memory
/**
* The way to free memory arranged for Bitmaps in native memory or just not GC'ed
* @source <a href="http://stackoverflow.com/a/7783511/918211">StackOverflow Thread</a>
*/
public static void stripImageView(ImageView view) {
if (view.getDrawable() instanceof BitmapDrawable) {
((BitmapDrawable) view.getDrawable()).getBitmap().recycle();
}
view.getDrawable().setCallback(null);
view.setImageDrawable(null);
@bepcyc
bepcyc / HeapInfo.java
Created January 30, 2012 12:59
Logging Heap info in Android
/**
* Logging Heap Info for Android
* @source <a href="http://stackoverflow.com/a/8018476/918211">StackOverflow Thread</a>
*/
public static void logHeap(Class clazz) {
final String APP = "MyApp";
Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/1048576d;
Double available = new Double(Debug.getNativeHeapSize())/1048576.0d;
Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0d;
DecimalFormat df = new DecimalFormat();
@bepcyc
bepcyc / pom.xml
Created January 30, 2012 13:08
maven plugin to run shell or batch scripts
<!--source: http://stackoverflow.com/a/3493919/918211-->
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution><!-- Run our version calculation script -->
<id>Version Calculation</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
@bepcyc
bepcyc / backup with apt.txt
Created February 15, 2012 13:55
BAckup and restore with aptitude in Ubuntu or Debian
before backup:
dpkg --get-selections > packages.txt
while restoring:
dpkg --clear-selections
dpkg --set-selections < packages.txt
aptitude install
sudo apt-get update
sudo apt-get -y install aptitude
sudo aptitude -y full-upgrade
##most common used programs
sudo apt-get -y install aptitude eclipse scala htop mc powertop chromium-browser nautilus-scripts-manager flac quodlibet nautilus-open-terminal vim vim-gtk git subversion-tools p7zip-full mplayer openssh-server python-pip mesa-utils
#oracle jdk 7
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java7-installer
@bepcyc
bepcyc / mplayer_audio_speedup.sh
Created June 11, 2013 15:52
speedup audio playback in mplayer (in this example ration is 1.5)
mplayer -af scaletempo -speed 1.5 $1
@bepcyc
bepcyc / recover_grub.sh
Created June 16, 2013 16:27
Recovering grub and solving EFI problems in ubuntu (13.04 - and maybe others) on ASUS N76 laptop.
#http://askubuntu.com/questions/88384/how-can-i-repair-grub-how-to-get-ubuntu-back-after-installing-windows
sudo mount /dev/sdax /mnt # make sure that sdax is correct!
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
sudo chroot /mnt
#optional - if you have a separate boot partition
mount /boot
update-grub
grub-install /dev/sda
update-grub # I'm not sure if this is necessary, but it doesn't hurt.
@bepcyc
bepcyc / wc_hdfs
Last active December 25, 2015 15:29 — forked from abicky/wc_hdfs
wc for Hadoop HDFS files
#!/bin/bash
#set correct path
HADOOP_HOME="/usr/lib/hadoop"
condition=""
fs="\t"
words=""
lines=""
chars=""
@bepcyc
bepcyc / jpgtoh264.sh
Created February 14, 2014 08:58
convert jpg files into h.264 video
#you'll need mencoder and x264 packages installed
#just add a video name like output.mp4 at the end
alias jpgtoh264="mencoder mf://*.jpg -nosound -of lavf -lavfopts format=mp4 -ovc x264 -x264encopts pass=1:bitrate=2000:crf=24 -mf type=jpg:fps=30 -o"