Skip to content

Instantly share code, notes, and snippets.

@lordfriend
lordfriend / Acylicity.java
Created May 12, 2018 16:15
Find a cycle in directed graph
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack;
public class Acyclicity {
private static int acyclic(ArrayList<Integer>[] adj) {
//write your code here
boolean[] visited = new boolean[adj.length];
// Advanced Problem: Checking Whether Any Intersection in a City is Reachable from Any Other
//Task. Compute the number of strongly connected components of a given directed graph with n vertices and m edges.
// Input Format. A graph is given in the standard format.
// Constraints. 1 ≤ n ≤ 10 4 , 0 ≤ m ≤ 10 4 .
// Output Format. Output the number of strongly connected components.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Stack;
@lordfriend
lordfriend / login.css
Created July 30, 2016 15:03
Deneb login page hack
@media (min-width: 723px) {
.center-box {
width: 360px !important;
margin-left: 10%;
}
.center-box-header {
position: fixed;
top: 0.8rem;
@lordfriend
lordfriend / index.html
Created April 28, 2015 10:12
selectable table row directive which support none-selectable td element
<table>
<tbody>
<tr selectab-tr="pickRow()">
<td>some data</td>
<td>some data</td>
<td class="none-selectable">
<a href="someurl">Click this link will not execute pickRow() function</a>
</td>
</tr>
</tbody>
@lordfriend
lordfriend / postCompile.js
Created November 19, 2014 07:31
grunt-markdown work with angular custom html
{
preCompile: function(src, context) {
var match = src.match(/<example>[\s\S]+?<\/example>/mg);
if(match && match.length > 0) {
match.forEach(function(example) {
var subMatch = example.match(/<file\s*name=".+?">[\s\S]+?<\/file>/mg);
var group, newExample = example,
htmlContent,
appName = 'example' + exampleCount + 'App',
htmlFileName,
@lordfriend
lordfriend / filter target by class
Created October 1, 2014 12:51
Use with event delegate when jquery is not available.
/**
* filter the event target for the nya-bs-option element.
* Use this method with event delegate. (attach a event handler on an parent element and listen the special children elements)
* @param target event.target node
* @param parent {object} the parent, where the event handler attached.
* @return the filtered target or null if no element satisfied the selector.
*/
var filterTarget = function(target, parent) {
var elem = target,
className;
## To create a custom config for a mod create a file with the same name
## as the jar file and append ".conf", for craftbukkit this would be
## "craftbukkit.jar.conf".
## The following config is an example that lists all possible options,
## without actually changing anything (it remaps the commands on
## themselves)
##
## General configuration. If this contains a setting called "file" the
## [commands], [start] and [parse_*] sections will be loaded from this
## other file
@lordfriend
lordfriend / monokai-webstorm.css
Last active August 29, 2015 14:01
monokai-webstorm color scheme for Brackets.io
.cm-s-monokai-webstorm.CodeMirror {
background-color: #272822;
color: #F8F8F2;
-webkit-font-smoothing: subpixel-antialiased;
}
.cm-s-monokai-webstorm.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid #f8f8f0;
z-index: 3;
}
@lordfriend
lordfriend / redis-q.js
Last active August 29, 2015 14:00
Wrap redis client using kriskowal/q promise
/**
* Wrap redis client using kriskowal/q promise
*/
var redis = require('redis');
var redisClient = redis.createClient();
var Multi = redis.Multi;
var Q = require('q');
var _ = require('underscore');
var object = function(o) {