Tuesday, April 13, 2021

Fix: Cannot use gmail and google drive on Safari

With the newer versions of ios, such as ios 13, you can customize your Safari features. While browsing the Experimental Webkit Features, I accidentally enabled requestIdleCallback, which made it impossible to login to any google accounts.

To disable requestIdleCallback on your device and re-gain access to your google accounts, do the following. First, go to the Settings app. Then choose the following series of options: Safari > Advanced > Experimental Features. Finally, disable requestIdleCallback.

Monday, February 11, 2019

GetContents() of Previous Version of Document in DFC

Documentum provides the Documentum Foundation Classes(DFC) as a Java library to connect to Documentum. When dealing with documents, it may be necessary to get prior versions, instead of the current version. But the sessionManager methods like getObjectByQualification seem to only work on the current r_object_id or current version of that document. Searching by r_object_id returns null or throws an exception.

In order to get older versions of the document, you must add ALL when you do getObjectByQualification(). Then you can get the prior or previous document or file without having to delete or destroy the latest one in any way. Below is a code example.
import java.io.*; 
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;

public class OlderVersions {

   public static String getOlderVersion(            
       String repositoryName,            
       IDfSessionManager sessionManager,            
       String documentName)     
   {
        IDfSession mySession = null;
        try {            
            mySession = sessionManager.getSession(repositoryName);
            // search for the object using the filename             
            IDfSysObject existingDoc = (IDfSysObject) mySession.getObjectByQualification(                 
                "dm_document (ALL) where object_name='" + documentName + "'"
            );
            if (existingDoc != null) {
            //object with that filename exists
                //then extract the contents of the file
                ByteArrayInputStream dumpedCorrection = existingDoc.getContent();
            } else {
                System.out.println("no file found for " + documentName);
            }
        } catch (Exception ex) {
                ex.printStackTrace();
        } finally {
            //  release the session
            sessionManager.release(mySession);
        }
    }
}

A similar thing can be done to find repeating attributes such as r_version_label. But in that case, the keyword is ANY:

IDfSysObject existingDoc = 
    (IDfSysObject) mySession.getObjectByQualification(                 
        "dm_document where object_name='" + documentName + 
        " and any r_version_label='THE_LABEL_NAME_YOU_USE''"
    );

The above can also be done directly in a DQL query. But this post is for people who don't know how to use DQL or who want to build on what they learned in the DFC Development Guide.

Thursday, June 21, 2018

How to Use Git Collaboratively


For those who already have experience with git the next step tends to be contributing to a code base multiple people are working on. There are two ways to contribute, have access to the repository or fork the repository and do a pull request with the commits you want included in the main repository.
Replace everything in red with your respective names
$ git clone https://github.com/github-group/repo-name.git

Gaining access to the repository

If the repo is in a group then you need group access from the group administrator then you need write permissions for the repository from the repository owner to start committing to it. Then you need to set your git remote origin to point to that specific repository

Pull requests

Pull requests are a useful way to share code of an existing repository you don’t have access to or from a branch that needs to be merged into the master branch

Adding features

When working on a code repository it’s important to do all new features on feature branches, preferably with the branch named after the feature being implemented.

$ git checkout -b branchname
$ git push origin branchname
When you want to switch to an existing branch:
$ git checkout branchname
But it’s also important to keep the branch updated with any changes on the master. The rebasing option puts all your recent commits on top of the pulled commits.
$ git stash
$ git checkout branchname
$ git pull --rebase origin master
$ git push
$ git stash pop

Commiting

In order to save your work you need to commit it. But make sure you only save the specific changes you want in your commit and nothing else. To do that it’s important to do git diff to verify everything that you’re staging and committing. It’s also a good practice to have only one small feature per commit so it is easy to track via the commit log, what changes have been made. It’s better to have several small functional commits than one large commit. However, if you would like to save WIP code then it’s important to do them on a separate branch then rebase or perform a pull request which will squash them all into one commit.

Undoing a commit

For a local commit you undo it by
$ git reset HEAD~
Then you’ll need to add them and commit them again.
For a remote commit
$ git revert commitnumber

Saving local changes without committing

Sometimes you have something that’s a WIP progress that you would like to keep but don’t feel ready to commit yet. However, you need to pull the changes from the remote code repository. That’s when you use git stash. It saves your local changes for you to regain later.
$ git stash
$ git pull
$ git stash pop
Occasionally there will be conflicts during a git stash pop which you then need to resolve in each file. They’ll show up as something like the following:
<<<<HEAD
======
>>> LOCAL CHANGES
You’ll need to keep the changes that work best for you and delete the rest.
 

Then, it’s important to either merge the changes back to remote


$ git push

OR do a git reset so that the resolution between the pull and the stash are not staged.


$ git reset HEAD~

Merging a feature branch into master

When a feature is fully developed and tested, it could be useful to everyone. Then it’s a good idea to merge it back into master.

If you have access to the official repository then do the following:

$ git checkout master
$ git pull origin master
$ git merge branchname
$ git push origin master

Otherwise do a pull request

Possible git workflow

$ git diff
$ git stash
$ git pull
$ git stash apply/pop
$ git diff
$ git add filename
$ git commit -m commitmessage
$ git push
$ git status
 

Tuesday, December 26, 2017

Basic Overview of Machine Learning in Speech Recognition

These days speech recognition is usually performed with different varieties of machine learning algorithms.

First, the algorithms are translated into models. Then the models are used to recognize aligned audio data which is then considered a fully functional speech recognizer for most text in that language. 
Finally, free form audio is inputted and out comes a transcription of what was previously only audio signals.

Friday, October 6, 2017

Useful bookmarklets made by other people

These bookmarklets were made by other people and I found them really useful but I no longer remember where I got them so if you know who made them please contact me and I'll add in the credits.

In browser text editor (useful for notes and making bookmarklets on the fly):\

javascript:(function(){window.open('data:text/html;charset=utf-8,<title>TextEditor</title><style>html{height: 100%;}body{margin:0;padding:4%;border:20px solid #eee;background-color:#fff;border-radius:2em}textarea{width:100%;height:100%;border:0 none;font-family:"Lucida Grande",sans-serif;font-size:2em;outline:none;color:#444}</style><body><textarea spellcheck="false" autofocus="autofocus"></textarea></body></html>', '_blank');})();

Estimated time to read:
javascript:(function(){function getTextNodesIn(c){var d=0,b=/^\s*$/;function a(g){if(g.nodeType==3){if(!b.test(g.nodeValue)){d+=g.nodeValue.split(" ").length}}else{for(var f=0,e=g.childNodes.length;f<e;++f){a(g.childNodes[f])}}}a(c);return d}alert("Estimated reading time: "+(getTextNodesIn(document.body)/250)+" minutes")}());

A bookmarklet version which allows local storage so no worries about closing it but Chrome currently considers it malicious: http://blog.getsetbro.com/Bookmarklet-to-make-your-browser-a-Text-Editor.html 

Saturday, June 17, 2017

Enabling the Windows Printer via Samba option after installing CUPS

Let’s say you have CUPS installed and now you want access to a Windows Printer on the network but it can only be accessed via SAMBA (SMB). However, on your CUPS Add Printer options you can’t find one to add a SAMBA printer.

In order to enable it, you need to open a terminal and run the following commands:

sudo apt install samba
sudo apt-get install libsmbclient
sudo apt-get install smbclient
sudo apt-get install python-smbc
sudo service cups restart

Then, Windows Printer via SAMBA should show up as one of your last options in Add Printer.

If the printer can only be accessed via login then you will have to add the credentials as part of the URI like this:
smb://username:password@domainname/printserver/V_2_24

Warning! If your username or password has reserved characters: ! * ' ( ) ; : @ & = + $ , / ? % # [ ] then you'll need to percent escape them to represent them correctly, especially for @; the URL will get confused with the @ used before the domain name.

Otherwise, the job will be held up in the queue and print jobs will return an internal error like this: Session setup failed: NT_STATUS_INTERNAL_ERROR

Happy Printing!

Resources:

Sunday, April 30, 2017

Dualbooting Debian and Windows when you have already installed Debian.

When dualbooting Linux and Windows, it is often recommended to install Windows first because of the various difficulties of doing it in reverse (e.g. GRUB breaking). However sometimes you want to keep Linux on your computer. So let's start this guide.

Hardware you will need:
Computer with a hard drive big enough and enough free space to fit (Windows 10 and Debian)
3 flash drives at least one must be 6GBs
Extra external hard drive

Main software necessary:
Copy of Windows 10 (product key too if necessary)
Copy of Debian (on your computer)

1. You start with a computer installed with Debian. Preferably, the boot and home directories will be in separate partitions. Make sure to backup all your important data to your external flash drive.

2. Then you need to install GParted on the first flash drive.

3. With GParted on the flash drive, you stick the flash drive into your laptop then load up the Grub bootloader to load the USB instead from the hard drive.
a. Then, since you're not running GParted from the home partition, you can load up GParted and resize your hard drive so you have unallocated space. Usually the home partition is the largest partition so you would shrink that if you have space. I'd estimate at least about 100GB free space for each OS if you're planning on keeping any data or installing any applications. After GParted is done then you can shut down the computer and pull out your GParted flash drive.

4. Install Windows on your second flash drive. Since debian will most likely not be installed using UEFI, on the flash drive you must use the msdos format with a partition which has the boot flag. If the flash drive won't mount after reformatting it, then manually mount it yourself in a convenient location like /home/USERNAME/Documents/WindowsMount where USERNAME should be replaced with your own username on Debian. Assuming your Windows was downloaded as a disk image, either mount the image or right click and extract all the contents of the ISO to the flash drive. Windows is about 4Gbs so use your larger flash drive. After you have installed Windows on your flash drive, you must turn off the computer and turn it back on. When it gets to the manufacturer logo screen like ASUS or Dell, then you must immediately press the key for your BIOS menu. It is manufacturer dependent so you'll have to look up MANUFACTURER BIOS menu key and from there you have to choose to load from your usb. Once you've saved the settings, you turn off your computer again and it should load directly from your Windows USB.

5. Once you've gone through all the Windows settings (and most importantly turning off automatic updates), then you need to download Rufus and Boot Repair then on your third flash drive you use Rufus to install Boot Repair on your flash drive. Make sure to label your flash drive. After you've done that you also need to make a grub.cfg file (it's basically to install grub on your flash drive) on your flash drive which references your flash drive by the label you gave it. So then you need to turn off your computer and then boot it and on the DELL screen you need to press your BIOS menu key again and once again tell your computer to load from a USB flash instead. This time the label should be clearly visible as your selection. Then you load up the Boot Repair OS and select repair disk and it'll restore your Grub loader so that the next time you turn on your computer you'll see both your Debian installation (and the various recovery modes and whatnot) and an option to load Windows 10.

Congratulations you have successfully dualbooted Debian and Windows 10!