This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContactChooser extends ActionBarActivity{ | |
@SuppressLint("NewApi") | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_contact_chooser); | |
Cursor cursor=getContentResolver().query( | |
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,null,null,null,null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
int main(){ | |
int n; | |
printf("Enter a number\n"); | |
scanf("%d",&n); | |
if(isPrime(n)){ | |
printf("Is prime number\n"); | |
}else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<netinet/in.h> | |
#include<signal.h> | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<sys/socket.h> | |
#include<sys/stat.h> | |
#include<sys/types.h> | |
#include<unistd.h> | |
#include<string.h> | |
void sig_handler(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch("api.example.com/user/1/posts", {header: {Authorization: "Bearer: <JWT TOKEN>"}}) | |
.then(res => res.json()) | |
.then(res => { | |
console.log(res) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ToHaveTypeStyleMatcher from "./ToHaveTypeStyleMatcher"; | |
describe("ToHaveTypeStyleMatcher", () => { | |
it("compare returns an object containing message and pass key", () => { | |
const prop = jest.fn(() => "TS-0000"); | |
const typestyleErrorMessageSnip = "TypeStyle does not match with actual, instead found"; | |
expect(typeof (ToHaveTypeStyleMatcher as any).toHaveTypeStyle().compare({prop}) === "object").toBeTruthy(); | |
const compare = (ToHaveTypeStyleMatcher as any).toHaveTypeStyle().compare({prop}); | |
expect(compare.message).toBeDefined(); | |
expect(compare.pass).toBeDefined(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Micro.Starter.Api { | |
public class BadClass { | |
private IService _service = new Service(); // it's a bad idea to do new inside a class, remember, new is glue | |
public void Greet(string name) { | |
Console.WriteLine(_service.Greet(name)); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Tests | |
{ | |
public class BadClassTest | |
{ | |
[Test] | |
public void TestGreetDoesNotThrowException() | |
{ | |
var unit = new BadClass(); | |
// var mock = new Mock<IService>(); (setup as well) | |
// use reflection to change the implementation under the hood, (unit._service = mock) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Micro.Starter.Api { | |
public interface IService { | |
string Greet(string name); | |
} | |
public class Service : IService { | |
public string Greet(string name) { | |
return $"Hello {name}"; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clean = (timeToWait, includeAbandoned = false) => { | |
if (!window.location.href.includes("/branches/stale")) { | |
return; | |
} | |
const branches = () => Array.from(document.querySelectorAll("li.Box-row.js-branch-row")); | |
const isMerged = (branch) => branch.querySelector("a.State.State--purple") !== null; | |
const isClosed = (branch) => branch.querySelector("a.State.State--red") !== null; | |
const isAbandoned = (branch) => branch.querySelector("a.btn.test-compare-link"); | |
const isMergedOrClosed = (branch) => isMerged(branch) || isClosed(branch); | |
const isMergedClosedOrAbandoned = (branch) => isMergedOrClosed(branch) || isAbandoned(branch); |
OlderNewer