Skip to content

Instantly share code, notes, and snippets.

@charyorde
charyorde / simple-unit-test
Created November 14, 2013 21:31
Unit test
public class KalturaVideoProviderTest {
private static final Logger log = LogManager.getLogger(KalturaVideoProviderTest.class);
private static KalturaVideoProvider kalturaVideoProvider;
private static KalturaClient kalturaClient;
private static CreateVideoActionBean bean ;
private static VideoService videoService;
private static VideoMetadataManager videoMetadataManager;
@charyorde
charyorde / mock-objects
Created November 14, 2013 20:13
Mock objects
Unit testing with Mock objects using Mockito
--------------------------------------------
2 concepts
- mock (create object using mocks)
- stub (modify a created object with stub). useful methods when stubbing are:
- when
- doReturn
How mock object works
---------------------
@charyorde
charyorde / async
Created September 12, 2013 11:56
Asynchronously(one after the other) execute bits of code
this.renderUI = function(res) {
var connected = (res.user != null && res.user.isConnected);
var contactsData = [];
if(connected) {
$j('#jive-modal-invite').trigger('close');
contactsData['contacts'] = gigya.socialize.getContacts({callback: function(response){ // How can I async js this line such that only when this returns should alert be called?
contactsData['contacts'] = response;
}});
alert(contactsData); // returns null
}
<html lang="en">
<title>Gigya Social Demo - getContacs</title>
<script type="text/javascript" lang="javascript" src="http://cdn.gigya.com/js/socialize.js?apikey=xx">
</script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
gigya.socialize.addEventHandlers({ onConnectionAdded: renderUI, onConnectionRemoved: renderUI });
gigya.socialize.showAddConnectionsUI({
@charyorde
charyorde / disfocus
Created August 27, 2013 14:21
set focus out of a callback function
<script type="text/javascript">
function onContributionWizardAfterAddEntry(entries) {
for(var i = 0; i < entries.length; i++) {
parent.top.$j("#externalVideoID").val(entries[i].entryId);
}
}
</script>
@charyorde
charyorde / dart.txt
Created October 20, 2011 16:22 — forked from paulmillr/dart.md
Leaked internal google dart email
---------- Forwarded message ----------
From: Mark S. Miller <[email protected]>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: [email protected]
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.