On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that gives developers lossless compression. This package is commonly used for compressing release tarballs, software packages, kernel images, and initramfs images. It is very widely distributed, statistically your average Linux or macOS system will have it installed for
This file contains 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 char fragmentShader_yuv420p[] = | |
{ | |
"precision mediump float;\n" | |
"uniform sampler2D Ytex;\n" | |
"uniform sampler2D Utex,Vtex;\n" | |
"varying vec2 vTextureCoord;\n" | |
"void main(void) {\n" | |
" float nx,ny,r,g,b,y,u,v;\n" | |
" mediump vec4 txl,ux,vx;" | |
" nx=vTextureCoord[0];\n" |
This file contains 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
class EnumExample { | |
private enum Status { | |
Init, Success, Failed, Loading | |
} | |
public static enum ProcessStatus { | |
LOAD_STAGE(Status.Init), | |
END_STAGE(Status.Failed); | |
This file contains 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 static int getMaxCodecInstanceByName(String name) { | |
final Vector<MediaCodec> codecs = new Vector<>(); | |
final MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, 1920, 1080); | |
MediaCodec codec = null; | |
for (int i = 0; i < max; i++) { | |
try { | |
codec = MediaCodec.createDecoderByType(MediaFormat.MIMETYPE_VIDEO_AVC); | |
codec.configure(format, null, null, 0); | |
codec.start(); |
This file contains 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
/* | |
You are climbing a stair case. It takes n steps to reach to the top. | |
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? | |
*/ | |
public class Solution { | |
public int climbStairs(int n) { | |
if(n == 0 || n == 1) return 1; | |
int finalWays = 0; | |
int f1 = 1; | |
int f2 = 1; |
This file contains 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
/* | |
Give a string, and a dictionary, find out if this string could be segmented by a space which's substring | |
are in this dictionary. | |
For example, String "leetcode", dictionary ["leet", "code"], | |
then return true, cause this string could be segmented as "leet code"; | |
*/ | |
public class Solution { | |
public boolean wordBreak(String str, Set<String> dict) { |
This file contains 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
/* | |
Implement an algorithm to detemine if a string has all unique characters. | |
What if you cannot use additional data structure. | |
*/ | |
// solution 1, with an array, time complexity = O(n), space complexity = O(1) | |
public class solution { | |
public boolean isUniqueChar(String str) { | |
if(str == null || str.length() == 0) | |
return false; |
This file contains 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
private fun hopAnimation() { | |
val animation = bottomContainer | |
.animate() | |
.translationYBy(-40f) | |
.alpha(0.9f) | |
.setDuration(400) | |
animation.withEndAction { | |
bottomContainer | |
.animate() | |
.alpha(0.5f) |
This file contains 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
// Generate data | |
int arraySize = 32768; | |
int data[] = new int[arraySize]; | |
Random rnd = new Random(0); | |
for (int c = 0; c < arraySize; ++c) | |
data[c] = rnd.nextInt() % 256; | |
// notice !!! | |
Arrays.sort(data); |
This file contains 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 PhotoMultipartRequest<T> extends Request<T> { | |
private static final String FILE_PART_NAME = "file"; | |
private MultipartEntityBuilder mBuilder = MultipartEntityBuilder.create(); | |
private final Response.Listener<T> mListener; | |
private final File mImageFile; | |
protected Map<String, String> headers; |
NewerOlder